我已经实现了一个instance
信号处理程序,我可以从中获取正在发送信号的进程的pid。有了这个pid,我试图使用命令
sigaction(SIGTSTP, &act, NULL)
但它显示消息
ls -l /proc/pid/exe
即使我正在执行命令" ps"该过程未列出。谁能告诉我如何获得这样的过程的路径或名称?
答案 0 :(得分:0)
您可以从pid获取流程的命令行,您可以阅读/proc/<pid>/cmdline
:
/proc/[pid]/cmdline
This read-only file holds the complete command line for the
process, unless the process is a zombie. In the latter case,
there is nothing in this file: that is, a read on this file
will return 0 characters. The command-line arguments appear
in this file as a set of strings separated by null bytes
('\0'), with a further null byte after the last string.
由此,您可以获得流程的路径或名称。