472,958 Members | 2,193 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,958 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 5015

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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: Andreas Kuntzagk | last post by:
Hi, following code: #!/usr/bin/python import os import sys def main():
21
by: John Lin | last post by:
Howdy, I want to know how to tell if a forked process is done. Actually, my real question is that I want to run a shell script inside of a python script, and after the shell script has...
4
by: Benoit Dejean | last post by:
hello, i have a question about forking processes atm, i have some code which i want to rewrite os.system("cd ~ && exec " + cmd + " & disown") i want to remove this os.system call
1
by: Alexander N. Spitzer | last post by:
I am trying to write a program that will fork a process, and execute the given task... the catch is that if it runs too long, I want to clean it up. this seemed pretty straight forward with a...
16
by: mishra | last post by:
Hi, i thied the following code.. # include<stdio.h> int main() { int a; printf("Hello..."); a=fork(); printf("hi\n"); return(0);
27
by: steve | last post by:
I was given the following code, and asked what the possible outputs could be. We're learning about processes and forking. int value; int main(){ int pid, number = 1; value = 2; pid = fork();...
2
by: Robin Haswell | last post by:
Hey guys I want to fork a process, but my scope has lots of stuff that the child won't need. Is it possible to clean the current environment of cruft so it is collected and freed? Basically I...
5
by: mutley | last post by:
for(i=1;i<CONFIG_POLLER_FORKS;i++) { if((pid = fork()) == 0) { server_num=i; break; } else { pids=pid;
1
by: 3srt | last post by:
Hello, I created a simple 'server' script that will accept input from a cgi script. The server will handle multiple connections on the same port, also. In a nut shell, this 'server' script will...
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
2
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.