Exit status of background process in Solaris

bcfd2104
bcfd2104 used Ask the Experts™
on
The project I'm working has multiple processes running. Some are windows, some are clients, some are servers. One of the processes is a TCPIP client where I changed a read to a read with timeout using a select. The process runs fine for a bit and then exits. I have no idea why it exits. The embedded print statements don't give any clue. Nothing shows up on the screen where the parent processes started it, nothing is in the redirected error file.

Is there any way to find out? UNIX type systems don't keep track of exit status like the old VMS systems of my misspent youth did. Do I need to write some type of exit handler, or is there an easier way?

BTW this is written in C++ running on Solaris 10
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Hi bcfd,

My guess is that the C++ program needs to explicitly catch the error so that you can handle it.

  try
  {
    Socket.Read ();
  } catch {Exception &E}


Kent

Author

Commented:
Although I've been doing this for over 30 years, I've seldom used exception handlers. I kind of understand the theory, but putting it in to practice may take a bit longer.

My question to your answer is "what exception am I catching?" The process terminates what I don't know why or what "the error" (referencing your answer above) that occurred is. If that makes sense.

If you can provide a bit more light, it would be appreciated.

D. Scruggs
How are these processes spawned?  Do they use fork()/exec(), system(), other?
Learn Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

Author

Commented:
system() - call from c++ program.
Hi bcfd,

I had assumed that you were sending the query through an open socket, not running and entire self-contained task.

User popen() instead of system().  You can then read the task's output and save or echo it.


Good Luck,
Kent
If all you want is the exit status of the command called from the system() call, the return value of system() is the exit status.  A lot of commands will return different exit values based on what the error was.

Author

Commented:
None

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial