Is kill function synchronous?

前端 未结 4 1319

Is the kill function in Linux synchronous? Say, I programatically call the kill function to terminate a process, will it return only when the inten

4条回答
  •  广开言路
    2021-01-07 19:48

    No, since it doesn't kill anything, it only sends a signal to the process.

    By default this signal can even be blocked or ignored.

    You can't block kill -9 which represents sending SIGKILL

    To wait for the process to die:

    while kill -0 PID_OF_THE_PROCESS 2>/dev/null; do sleep 1; done
    

提交回复
热议问题