I do the usual fork + exec combination:
int sockets [2];
socketpair (AF_LOCAL, SOCK_STREAM, 0, sockets);
int pid = fork ();
if (pid == 0) {
// child
dup2 (sockets[0], STDIN_FILENO);
dup2 (sockets[0], STDOUT_FILENO);
execvp (argv[0], argv);
_exit (123);
}
// parent
close (sockets[0]);
// TODO wait and see if child crashes
Is it possible to wait until child crashes or begins waiting on read(...)?