When writing Apache module, popen( svn ) fails with termination status 256
I'd like to write an online SVN repository browser. I've decided to implement it as an Apache module, wrapping around the command line client (for the time being). As I'm getting started, I have the following code:
FILE *f;
f = popen("/usr/local/bin/svn cat http://myrepo/svn/sh开发者_如何学编程ell.c", "r");
char buf[1025];
if (f) {
ap_rputs("open ok\n", r);
}
else {
ap_rputs("not open ok\n", r);
}
while (fgets(buf, 1024, f) != NULL) {
ap_rprintf(r,"%s<br />", buf );
}
ap_rprintf(r, "return: %d\n", pclose(f));
This command fails, with the termination status 256. What error does this correspond to? I've been unable to find this documentation.
Simple calls such as "cat somefile" are successfully printed out. In fact, the call "svn info path-to-a-working-copy" are successful. However I'd like to deal with possibly remote repositories for flexibility.
Do you have any suggestions?
Edit: exit codes are should fall in the range 0-255. This one clearly does not. What does this tell me?
Edit2: as a test case, I created a bash script which would run the desired SVN command, then print its return value. The expected SVN behavior was not encountered, and the script printed "1" as the exit value for SVN. This was visible on the browser end.
Just a guess: Perhaps svn cat
on a URL is causing svn to want to prompt for username/password?
When you created the bash script, did you redirect stderr to stdout to try and catch any error messages?
精彩评论