{"id":310,"date":"2009-05-18T11:20:10","date_gmt":"2009-05-18T15:20:10","guid":{"rendered":"http:\/\/www.timelordz.com\/blog\/?p=310"},"modified":"2009-05-18T11:20:10","modified_gmt":"2009-05-18T15:20:10","slug":"strace-process-signal-monitoring","status":"publish","type":"post","link":"https:\/\/www.timelordz.com\/blog\/2009\/05\/strace-process-signal-monitoring\/","title":{"rendered":"Strace process signal monitoring"},"content":{"rendered":"<div class=\"moz-text-plain\" style=\"font-family: -moz-fixed; font-size: 12px;\" lang=\"x-western\">\n<pre>While I am no strace zen master, I did discover that in addition to\r\nsystem calls, strace will also show any signals a process gets. Nifty eh?\r\n\r\nFurther, you can attach strace to a running process - you don't have to\r\nstart a process with it initially.\r\n\r\nThis can be super handy to tell if a process is even receiving signals\r\nyou are sending to it - thus you can tell if it is being mean and\r\nignoring them or never getting them in the first place. For example.\r\n\r\nIn shell one:\r\n\r\n<span style=\"color: #33cccc;\">root@Anduril:~# vim blah\r\n{ctrl z}\r\n[1]+  Stopped                 vim blah\r\nroot@Anduril:~# jobs\r\n[1]+  Stopped                 vim blah\r\nroot@Anduril:~# pgrep vim\r\n22264\r\nroot@Anduril:~# strace -p 22264<\/span>\r\n\r\nIn shell two, now kill the process:\r\n\r\n<span style=\"color: #33cccc;\">root@Anduril:~# kill -9 22264\r\nroot@Anduril:~# pgrep vim<\/span>\r\n\r\nNow return to shell one and you will see strace caught and displayed the\r\nsignal received:\r\n\r\n<span style=\"color: #33cccc;\">Process 22264 attached - interrupt to quit\r\n+++ killed by SIGKILL +++\r\nProcess 22264 detached\r\n[1]+  Killed                  vim blah<\/span>\r\n\r\n(As a note, you can also use lsof -p 22264 to view the files vim has\r\nopen as well.)\r\n\r\nWhy can't you kill some processes?\r\n\r\nIf a process is in an uninterpretable sleep state (listed as D for\r\nexample in ps ) it will not receive signals until it is active again.\r\nKill it all you want, but its out to lunch and wont care.\r\n\r\nIf a process has a defunct parent process, you might need to kill it -\r\nand not the child. Parent processes are easily identified with pstree:\r\n\r\n<span style=\"color: #33cccc;\">r<\/span><span style=\"color: #33cccc;\">oot@Anduril:~# pstree  -p | grep vim\r\n        |                       |-bash(22180)---bash(22197)---vim(22663)<\/span>\r\n\r\nGood hunting!\r\n\r\nPete<\/pre>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>While I am no strace zen master, I did discover that in addition to system calls, strace will also show any signals a process gets. Nifty eh? Further, you can attach strace to a running process &#8211; you don&#8217;t have to start a process with it initially. This can be super handy to tell if [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[14],"class_list":["post-310","post","type-post","status-publish","format-standard","hentry","category-linux","tag-linux-strace"],"_links":{"self":[{"href":"https:\/\/www.timelordz.com\/blog\/wp-json\/wp\/v2\/posts\/310","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.timelordz.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.timelordz.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.timelordz.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.timelordz.com\/blog\/wp-json\/wp\/v2\/comments?post=310"}],"version-history":[{"count":1,"href":"https:\/\/www.timelordz.com\/blog\/wp-json\/wp\/v2\/posts\/310\/revisions"}],"predecessor-version":[{"id":311,"href":"https:\/\/www.timelordz.com\/blog\/wp-json\/wp\/v2\/posts\/310\/revisions\/311"}],"wp:attachment":[{"href":"https:\/\/www.timelordz.com\/blog\/wp-json\/wp\/v2\/media?parent=310"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.timelordz.com\/blog\/wp-json\/wp\/v2\/categories?post=310"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.timelordz.com\/blog\/wp-json\/wp\/v2\/tags?post=310"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}