471,092 Members | 1,058 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,092 software developers and data experts.

fork defunct process, already forked twice

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
1 4873

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.

Similar topics

13 posts views Thread by Andreas Kuntzagk | last post: by
21 posts views Thread by John Lin | last post: by
4 posts views Thread by Benoit Dejean | last post: by
16 posts views Thread by mishra | last post: by
27 posts views Thread by steve | last post: by
2 posts views Thread by Robin Haswell | last post: by
5 posts views Thread by mutley | last post: by
1 post views Thread by 3srt | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.