Jump to content

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


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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.