________________________________________________________________________
Applicable Environment
________________________________________________________________________
- Topic: Wait on death of process
- SDP: 6.4.1
- Target: Any supported target
________________________________________________________________________
Recommendation________________________________________________________________________
Sample code:
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <err.h>
#include <fcntl.h>
#include <sys/procfs.h>
static char *whys[] = {
"REQUESTED",
"SIGNALLED",
"FAULTED",
"JOBCONTROL",
"TERMINATED",
"CHILD",
"EXEC"
};
int main( int argc, char *argv[] ) {
procfs_status status;
procfs_run run;
pid_t pid = strtoul( argv[1], NULL, 0 );
char path[50];
int fd;
sprintf( path, "/proc/%d/as", pid );
if ( -1 == ( fd = open( path, O_RDWR ) ) )
err( EXIT_FAILURE, "open(%s)", path );
memset( &run, 0, sizeof run );
if ( EOK != ( errno = devctl( fd, DCMD_PROC_WAITSTOP, &status, sizeof status, NULL ) ) )
err( EXIT_FAILURE, "devctl(%s,DCMD_PROC_WAITSTOP)", path );
close( fd );
printf( "%d exited. Why=%x (%s)\n", pid, status.why, whys[status.why] );
return EXIT_SUCCESS;
}
________________________________________________________________________
NOTE:
This entry has been validated against the SDP version listed above. Use
caution when considering this advice for any other SDP version. For
supported releases, please reach out to QNX Technical Support if you have any questions/concerns. ________________________________________________________________________