杀死系统调用 C,权限
Kill system call C, permission
为什么在 C 中发送 kill 系统调用不需要 root 权限或 sudoer 权限?我试图使用 kill 系统调用终止 C 中的进程。我虽然需要我 运行 以 root 身份进行处理,但事实并非如此。通常在通过bash终端发送kill系统调用时,我们需要使用sudo,那么为什么在使用C时不需要?
如果您在命令行上调用程序 kill
而您没有所需的权限,那么它将失败。在 C 程序中使用 kill()
时也会发生同样的事情。有关信息,请参阅 man 页面。
特别是关于 return 值 EPERM
的部分是 return 如果用户无权发送到列出的任何进程 ID。以及描述:
For a process to have permission to send a signal to a process designated by pid, unless the sending process has appropriate privileges, the real or effective user ID of the sending process shall match the real or saved set-user-ID of the receiving process.
为什么在 C 中发送 kill 系统调用不需要 root 权限或 sudoer 权限?我试图使用 kill 系统调用终止 C 中的进程。我虽然需要我 运行 以 root 身份进行处理,但事实并非如此。通常在通过bash终端发送kill系统调用时,我们需要使用sudo,那么为什么在使用C时不需要?
如果您在命令行上调用程序 kill
而您没有所需的权限,那么它将失败。在 C 程序中使用 kill()
时也会发生同样的事情。有关信息,请参阅 man 页面。
特别是关于 return 值 EPERM
的部分是 return 如果用户无权发送到列出的任何进程 ID。以及描述:
For a process to have permission to send a signal to a process designated by pid, unless the sending process has appropriate privileges, the real or effective user ID of the sending process shall match the real or saved set-user-ID of the receiving process.