473,385 Members | 1,546 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 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 5043

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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.