I am trying to execute another command line process in parallel with the current process. However, I understand that the command line program sometimes crashes, and this also kills my main program.
pid = fork();
char *argv[] = { stuff.. };
if (pid == 0) {
int rc = execv("command line program...", argv);
}
if (pid > 0) {
waitpid(pid, 0, 0);
}
Is there a way to save my main program after the command line program dies abnormally? Thank you
[UPDATE]: Yes, the main process is written to a file where the command line is read, but this is a regular file, not a channel. I get segfault.
, . . - , , .