Jump to content

Acquire "human readable" string when given an exit codes post pcntl_wait()


jefftanner

Recommended Posts

I am using PHP process controls, and I want to get a "human readable" string based upon exit status. Is there such a function?

 

Example code:

		$cid = pcntl_wait($status); //Protect against Zombie children
	print "we are in parent $pid post wait child $cid AFTER\n";
	print "pid child $cid -- status $status.\n";
	if(pcntl_wifexited($status)) {
		$exit_code = pcntl_wexitstatus($status);
		print "pid child $cid returned exit code: $exit_code.\n";
	}
	else if (pcntl_wifstopped($status)) {
		$stop_signal = pcntl_wstopsig($status);
		print "pid child $cid is currently stopped: $stop_signal.\n";
	}
	else if (pcntl_wifsignaled($status)) {
		$terminate_signal = pcntl_wtermsig($status);
		print "pid child $cid terminated due to a signal $terminate_signal.\n";
	}
	else {
		print "child $cid was unnaturally terminated.\n";
	}

 

So for each of these stopped, terminated, and exit codes, I want an interpretation in string form.

I don't think there is .. if there was, it would be mentioned in the pcntl documentation somewhere.  You can use the signal constants though, like SIGSTOP, SIGHUP, etc etc.

 

For exit status, that is defined by the application, so there is never a standard string representation of that.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.