Questions tagged [pclose]

In C, the pclose() function closes a stream that was opened by popen().

In C, the pclose() function closes a stream that was opened by popen(), waits for the command to terminate, and returns the termination status of the process that was running the command interpreter. However, if a call caused the termination status to be unavailable to pclose(), then pclose() returns -1 with errno set to ECHILD to report this situation. This can happen if the application calls one of the following functions:

  • wait()
  • waitpid() with the pid argument of -1 or equal to the process ID of the command interpreter.

In any case, pclose() does not return before the child process created by popen() terminates.

If some error prevents the command interpreter from executing after the child process is created, the return value from pclose() is as if the command language interpreter had terminated using exit(127) or _exit(127).

Source: Man page for pclose() -- close pipe stream at mkSoftware

33 questions
0
votes
3 answers

How can I get the processID created by popen?

I have to execute command and return the result like cmd. I just found out the only method for this requirement.I used popen function to execute command and return the result,and then used pclose() function to close the stream and process. But if…
quanrock
  • 89
  • 2
  • 10
0
votes
0 answers

How could a Linux application get terminated by a signal number greater than 63 (WTERMSIG() > 63)?

How can WTERMSIG() evaluate to a value greater than 63, such as 67 or 123? Here's how it happens. I'm using popen() to run unbuffer which in turn runs a shell script. The next block of code is a while() loop that reads from the file descriptor…
-1
votes
2 answers

How can I keep a script running in the background-not working

I am trying to fire up the Ratchet's chat-server.php file which is needed to fire up the socket server from a php file so that whenever a client visits the page the server is started but its not happening. This chat-server.php file needs to be run…
Ayan
  • 2,738
  • 3
  • 35
  • 76
1 2
3