1

I'm looking how I can get exit code from non-child process.

As we all know there are few functions to work with child processes such as wait/waitpid. With this function we can wait until child process will be closed and get exit error code. But this works only with child processes.

Actually I'm looking for Windows analogue of GetExitCodeProcess. In Windows we can open process by calling OpenProcess and then work directly with returned handle. So we can call GetExitCodeProcess function and retrieve status.

Is there something same in Linux for working with non-child processes?

Csq
  • 5,775
  • 6
  • 26
  • 39
user922871
  • 435
  • 2
  • 6
  • 17
  • check http://stackoverflow.com/questions/20193464/how-to-get-the-exit-code-of-program-invoked-by-system-call – CS Pei Sep 30 '14 at 20:36
  • @JohnSmith - That question is about the system() call which is implemented using fork + exec, which implies that the process is a child process. The OP is asking about non-child processes that were started by another parent. – codenheim Sep 30 '14 at 20:38

1 Answers1

1

There is no POSIX or otherwise standard UNIX / Linux call to do what you ask, that I know of, but you can possibly accomplish it on Linux (or other UNIX) using the procfs. Many non-standard extensions were innovated with the procfs.

If the parent has not yet waited on the child, the return code may still be around.

See: Linux, where are the return codes stored of system daemons and other processes?

Community
  • 1
  • 1
codenheim
  • 20,467
  • 1
  • 59
  • 80