How to prevent SIGINT in child process from propagating to and killing parent process?
问题 I've recently learned how to do the whole fork/exec/wait thing and ended up writing some code that looked like this stripped down: #include <stdio.h> #include <stdlib.h> #include <unistd.h> int main() { pid_t x = fork(); if (x == 0) { execlp("sqlite3", "sqlite3"); printf("exec failed\n"); } else { wait(NULL); printf("Hi\n"); } } This works out pretty well, and actually ends up opening the sqlite3 shell, but there's one problem. If you Ctrl + C out of the sqlite3 shell, then it also terminates