Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Developing U++ » U++ Developers corner » TheIDE zombie problem
TheIDE zombie problem [message #7453] Sat, 30 December 2006 09:36 Go to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
TheIDE leaves launched programs as zombies.

Yes, I am well aware that you have to call wait for cleanup. However, in TheIDE, that is not entirely possible, because we need GUI to continue running.

Therefore we need a "start&forget" way of launching programs.

Somewhere I have found a recipe to solve the problem using singnals; the code is at ide/Host.cpp starting at line 156. But it does not seem to work well.

Any ideas?

Mirek
Re: TheIDE zombie problem [message #7454 is a reply to message #7453] Sat, 30 December 2006 11:04 Go to previous messageGo to next message
lundman is currently offline  lundman
Messages: 175
Registered: March 2006
Location: Tokyo
Experienced Member
Well, you can start children you don't need to wait on, if you really do not need to know when they die. Just start a new process group (setsid()) before calling.

if (!fork()) {
  // as child
  close(fileno(STDIN));
  close(fileno(STDOUT));
  close(fileno(STDERR));
  setsid();
  execve(argv[0], argv, env);
  /* not reached */
}


Iwould assume that's fine for "execute", but if you want to run it in debugged, you may need/want the SIGCHLD to know when it dies? Or if you are using stdin/out, deal/ignore SIGPIPE.

I can certainly fix it, so it leaves no zombies, if that is all that is needed.
Re: TheIDE zombie problem [message #7455 is a reply to message #7454] Sat, 30 December 2006 11:32 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
lundman wrote on Sat, 30 December 2006 05:04


Iwould assume that's fine for "execute", but if you want to run it in debugged, you may need/want the SIGCHLD to know when it dies? Or if you are using stdin/out, deal/ignore SIGPIPE.



For debugging that really is not problem, the wait is (ok, should be Smile called there (it is another mode..)

Mirek
Re: TheIDE zombie problem [message #7456 is a reply to message #7454] Sat, 30 December 2006 11:56 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
lundman wrote on Sat, 30 December 2006 05:04

Well, you can start children you don't need to wait on, if you really do not need to know when they die. Just start a new process group (setsid()) before calling.

if (!fork()) {
  // as child
  close(fileno(STDIN));
  close(fileno(STDOUT));
  close(fileno(STDERR));
  setsid();
  execve(argv[0], argv, env);
  /* not reached */
}


Iwould assume that's fine for "execute", but if you want to run it in debugged, you may need/want the SIGCHLD to know when it dies? Or if you are using stdin/out, deal/ignore SIGPIPE.

I can certainly fix it, so it leaves no zombies, if that is all that is needed.



Well I am afraid that above solution is not correct - you have to wait for pid returned from fork in the parent process.

Mirek
Re: TheIDE zombie problem [message #7458 is a reply to message #7456] Sat, 30 December 2006 12:10 Go to previous messageGo to next message
lundman is currently offline  lundman
Messages: 175
Registered: March 2006
Location: Tokyo
Experienced Member

Code meant as pseudo example, not "as is". But I can take a look at it Monday, no need to do that on "my time" Smile


Re: TheIDE zombie problem [message #7461 is a reply to message #7458] Sat, 30 December 2006 13:50 Go to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
lundman wrote on Sat, 30 December 2006 06:10


Code meant as pseudo example, not "as is". But I can take a look at it Monday, no need to do that on "my time" Smile





Fixed...
Previous Topic: Twain - support for scanners - needed
Next Topic: Extensions of X-Server
Goto Forum:
  


Current Time: Fri Apr 19 16:28:41 CEST 2024

Total time taken to generate the page: 4.06728 seconds