From the documentation of system()
(emphasis/bold mine):
The
system()
library function uses fork(2) to create a child process
that executes the shell command specified in command using execl(3)
as follows:execl("/bin/sh", "sh", "-c", command, (char *) 0);
system()
returns after the command has been completed.During execution of the command, SIGCHLD will be blocked, and SIGINT and SIGQUIT will be ignored, in the process that calls
system()
(these signals will be handled according to their defaults inside the child process that executes command).
Which explains your behavior.