Linux系统编程48 信号 - abort() system()

abort()

NAME
       abort - cause abnormal process termination 进程异常终止

SYNOPSIS
       #include <stdlib.h>

       void abort(void);

当前进程给自己发送一个 SIGABRT 信号,异常终止当前进程,并产生 coredump文件。

RETURN VALUE
       The abort() function never returns.

system()

NAME
system - execute a shell command 调用 shell 来完成一条shell 命令

SYNOPSIS
       #include <stdlib.h>

       int system(const char *command);

调用 shell 来完成一条shell 命令,可以简单理解为 fork()+execXX()+wait() 的组合

如果想在有信号的程序当中正常使用 system(),需要阻塞SIGCHLD信号,忽略SIGINT信号和SIGQUIT信号

猜你喜欢

转载自blog.csdn.net/LinuxArmbiggod/article/details/114073029