LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 03-15-2005, 11:31 AM   #1
gothrog
Member
 
Registered: Jun 2004
Distribution: Yellow Dog, Fedora, RedHat, Centos, Ubuntu, Suse Linux
Posts: 106

Rep: Reputation: 15
Post system() calls causing Zombies...!!! Apache expert


Hello,

I am running apache2 and C++ executables as .cgi scripts. In the cgi script I use a system() call to execute another program when the user commands it to through the browser, and it should not close until the user issues another command.

When using the browser to launch the other program it immediately becomes a zombie process:
ps -ef | grep (name)
root 28829 1 0 09:22 ? 00:00:00 /usr/local/(full path)

Now from using google searches I have found that a possible cause to why this is happening is the use of system() calls.

In everyplace I have looked so far no one seems to know why the system() call won't work.

What I figure is that it must be a problem with the way the threading works within Apache, I am trying to figure out if there is anything I can do or add to Apache that will allow the execution of these processes without causing them to become ZOMBIES.

Does anyone have any lead or ideas I can try?

Last edited by gothrog; 03-17-2005 at 09:56 AM.
 
Old 03-15-2005, 11:38 AM   #2
Matir
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Ubuntu
Posts: 8,507

Rep: Reputation: 126Reputation: 126
This is really more of a programming question than a networking question. In any case, can you post the relevant section of your code so we can see exactly what is going on? What is the "other program" being executed? You may want to look at this. What behavior occurs when executing the program from the command line?
 
Old 03-17-2005, 10:13 AM   #3
gothrog
Member
 
Registered: Jun 2004
Distribution: Yellow Dog, Fedora, RedHat, Centos, Ubuntu, Suse Linux
Posts: 106

Original Poster
Rep: Reputation: 15
I can't even launch an xterm window with a system() call.
C++ Code:
system("xterm &");

Matir, Can you tell me if you can launch an xterm from your browser? If you can I'll be extermely surprized and I would like to know how you did that.

I don't think you can solve this issue with fixing my code.

Apache or the browsers doesn't seem to allow the opening of a konsule or xterm. I even checked the return statement of the system() call and it says the call executed properly, but if it executed properly why the heck doesn't my xterm pop up.

My main reason for this post is to make people aware that have the capablity to solve this problem and hope they can try and do something about it, or at least look into it. Just do some searches and you will see that I'm not the only one with this problem.

Again if anyone has any idea for a solution please post it.
 
Old 03-17-2005, 10:56 AM   #4
gothrog
Member
 
Registered: Jun 2004
Distribution: Yellow Dog, Fedora, RedHat, Centos, Ubuntu, Suse Linux
Posts: 106

Original Poster
Rep: Reputation: 15
That is thing that I'm not too sure about. I don't do anything in the program that I'm aware of to make it a zombie. I don't create any threads, I just let the apache handle all the threading and processes of the cgi script.

I can't even open an xterm with a system call when executing from the browser:
c++ code: system("xterm &");

When I do a ps -aux I find an extra sc.cgi script that is defunct. To me it seems like the extra commands get defuncted, I also see the other process running that is sleeping.
root 15105 0.0 0.0 0 0 ? Z 10:43 0:00 [sc.cgi] <defunct>
root 15132 0.0 0.0 3232 940 ? S 10:43 0:00 /usr/local/

The script is launching another program. This program is supposed to stay running, but instead the script becomes defuncted, and the other one goes to sleep.

I have no idea what is going on with apache. This is just what happens. Again if anyone has any ideas it would be greatly appreciated.

Mike


Quote:
Originally Posted by M.Hirsch
Zombies are children who died and their parent didn't care about it. (...don't quote me out of context on this )

Are you catching or ignoring the CHLD signal in your C++ app? Either of these should prevent zombies.

hth,
M.

Last edited by gothrog; 03-17-2005 at 10:58 AM.
 
Old 03-17-2005, 12:38 PM   #5
Matir
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Ubuntu
Posts: 8,507

Rep: Reputation: 126Reputation: 126
In your original post, you did not mention that it was a GUI app. And adding the & to the end of the call causes it to background, and thusly the C++ app to terminate. Further, you'd have to set the DISPLAY environment variable to get anything GUI to work. Just like you can't open xterm from a virtual terminal without setting DISPLAY.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Making system calls in C++ harisund Programming 4 11-26-2005 06:58 PM
Some system calls Spooky Programming 1 11-24-2004 11:17 AM
counting system calls eltn Programming 2 10-15-2004 03:32 PM
over riding system calls djgerbavore Programming 11 08-20-2004 01:03 AM
System Calls file Hady Programming 1 12-13-2003 01:14 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 01:47 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration