468,456 Members | 1,850 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,456 developers. It's quick & easy.

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 4754

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
reply views Thread by NPC403 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.