Link to home
Start Free TrialLog in
Avatar of kuang
kuang

asked on

C CGI Program system call problem

I have a problem with my C cgi program on my NCSA HTTPD v1.5.
THe code look like:
fail = system("the_program_need_to_be_executed 1>/dev/null 2>/dev/null");
printf("show the fail value %d<P>",fail);
if (!fail)
        ............;

else
        ............;

The system call will return 0 if it is successful.
If I ran it from command line, it takes less then 1 sec to finish it.
When I ran it from the browser, it does not print the line.  THe browser seems
to wait for a long time.  I check the process status, the fork child processes
still sittng there.  How can I solve the problem and how can I trap it?

Thank you


                                                                     
                                                         
ASKER CERTIFIED SOLUTION
Avatar of Philippe
Philippe

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of kuang
kuang

ASKER

I did ran a test(non cgi) as nobody(web uid).  it works.
I did run that cgi program and try to pipe the stdout and stderr to files which have been generateed but nothing in side the files.

If I comment the system call out it ran ok.

is there anything I can try further?

Thank you

Avatar of ozo
Could path be set differently when you run as nobody and
when the server runs your program?
Did you try specifying the full pathname to the_program_need_to_be_executed?


Kuang,

so we have a program which generates no output, works fine when you run it from prompt and blocks without givin an error message when run from the server.

Did you try ozo's comment? To have the same environment as nobody
would have ,try a 'su - nobody' (the '-' says that you also want to change the environment). You should then be in exactly the same situation as the browser.

Is there any chance that the machine on which you test your script and the machine on which the server runs are not the same?

What does your program actually do? Is it a script or a program you wrote. Does it access any remote files or do something it could need permission for? If you have access to the source of that program you could have it print out some debug information.

We might be able to help you more if you tell us more about that program.

  cheers,

   Philippe