By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,925 Members | 732 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,925 IT Pros & Developers. It's quick & easy.

fork defunct process, already forked twice

P: n/a
Hi I want to have a wait page while the rest of the cgi does its
process, but it seems like the wait page waits till everything is
complete and never appears. I've tried forking twice already as
suggested in a faq, but it still doesnt seem to work. Below is what I
have done:

pid = fork()
if (pid == 0){
printf ("http://my.wait.page");
exit (100);
else if (pid < 0){
//output a fork error message;
exit (0);
else{
gpid = fork();
if (gpid < 0){
// output a fork error message;
exit (0);
else if (gpid == 0){
exit (100);
else{
/* do my long process */
return;
}
}

Any help will be much appreciated. Thanks.

Eric

Aug 23 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a

vduber6er wrote:
Hi I want to have a wait page while the rest of the cgi does its
process, but it seems like the wait page waits till everything is
complete and never appears. I've tried forking twice already as
suggested in a faq, but it still doesnt seem to work. Below is what I
have done:

pid = fork()
if (pid == 0){
printf ("http://my.wait.page");
exit (100);
else if (pid < 0){
//output a fork error message;
exit (0);
else{
gpid = fork();
if (gpid < 0){
// output a fork error message;
exit (0);
else if (gpid == 0){
exit (100);
else{
/* do my long process */
return;
}
}
fork() isn't a standard C function, and your problem is off-topic here
You'll get a better answer in one of the Unix or CGI newsgroups

But...

take a look at your second fork(). You don't execute your "long
process" in the grandchild process, but in the child process instead.
Your grandchild process just exits with a return value of 100. You
either have a useless fork() or your logic is misplaced.

Try changing your code so that...

else if (gpid == 0) {
/* do the long process */
else exit(100); /* parent process */

HTH
--
Lew Pitcher

Aug 23 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.