{"id":37,"date":"2010-02-01T14:48:32","date_gmt":"2010-02-01T13:48:32","guid":{"rendered":"http:\/\/toderu.ro\/blog\/?p=37"},"modified":"2010-02-01T14:48:32","modified_gmt":"2010-02-01T13:48:32","slug":"strace-multiple-processes","status":"publish","type":"post","link":"https:\/\/kb.toderu.ro\/?p=37","title":{"rendered":"strace multiple processes"},"content":{"rendered":"<p>\t\t\t\tc ~ <code>$ strace -f -s 128 $(pidof httpd |sed 's\/\\([0-9]*\\)\/\\-p \\1\/g')<\/p>\n<p>Quite simple really, just use sed to make the necessary command line switches.<\/p>\n<p>strace wants to have the PIDs passed one per '-p' switch. It would be nice to have a -p 3434,4565,4342 option but oh<br \/>\nwell. sed with a easy replace handles all that's necessary.<\/p>\n<p>Observe the output of pidof<\/p>\n<p>c ~ <code>$ pidof httpd<br \/>\n9629 9439 9428 9427 9426 9425 9424 9420<\/code><\/p>\n<p>Wrap with sed to create multiple -p switches.<\/p>\n<p>c ~ <code>$ pidof httpd |sed 's\/\\([0-9]*\\)\/\\-p \\1\/g'<br \/>\n-p 9629 -p 9439 -p 9428 -p 9427 -p 9426 -p 9425 -p 9424 -p 9420<\/code><\/p>\n<p>Now combine with strace.<\/p>\n<p>c ~ <code>$ strace $(pidof httpd |sed 's\/\\([0-9]*\\)\/\\-p \\1\/g')<br \/>\ncarbon share # strace $(pidof apache2 |sed 's\/\\([0-9]*\\)\/\\-p \\1\/g')<br \/>\nProcess 9629 attached - interrupt to quit<br \/>\nProcess 9439 attached - interrupt to quit<br \/>\nProcess 9428 attached - interrupt to quit<br \/>\nProcess 9427 attached - interrupt to quit<br \/>\nProcess 9426 attached - interrupt to quit<br \/>\nProcess 9425 attached - interrupt to quit<br \/>\nProcess 9424 attached - interrupt to quit<br \/>\nProcess 9420 attached - interrupt to quit<br \/>\n[pid  9439] semop(10846209, 0xb7bd9a28, 1 <unfinished ...><br \/>\n[pid  9629] semop(10846209, 0xb7bd9a28, 1 <unfinished ...><br \/>\n[pid  9428] epoll_wait(10,  <unfinished ...><br \/>\n[pid  9427] semop(10846209, 0xb7bd9a28, 1 <unfinished ...><br \/>\n[pid  9426] semop(10846209, 0xb7bd9a28, 1 <unfinished ...><br \/>\n[pid  9424] semop(10846209, 0xb7bd9a28, 1 <unfinished ...><br \/>\n[pid  9420] select(0, NULL, NULL, NULL, {0, 730000} <unfinished ...><br \/>\n[pid  9425] semop(10846209, 0xb7bd9a28, 1 <unfinished ...><br \/>\n[pid  9420] <... select resumed> )      = 0 (Timeout)<br \/>\n[pid  9420] waitpid(-1, 0xbff91918, WNOHANG|WSTOPPED) = 0<br \/>\n[pid  9420] select(0, NULL, NULL, NULL, {1, 0}) = 0 (Timeout)<\/code><\/p>\n<p>Now go debug some PHP or CGI application in the guts <\/p>\n<p>Source: http:\/\/edoceo.com\/exemplar\/strace-multiple-processes\t\t<\/p>\n","protected":false},"excerpt":{"rendered":"<p>c ~ $ strace -f -s 128 $(pidof httpd |sed &#8216;s\/\\([0-9]*\\)\/\\-p \\1\/g&#8217;) Quite simple really, just use sed to make the necessary command line switches. strace wants to have the PIDs passed one per &#8216;-p&#8217; switch. It would be nice to have a -p 3434,4565,4342 option but oh well. sed with a easy replace handles [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[19,5],"tags":[],"class_list":["post-37","post","type-post","status-publish","format-standard","hentry","category-bash","category-linux"],"_links":{"self":[{"href":"https:\/\/kb.toderu.ro\/index.php?rest_route=\/wp\/v2\/posts\/37","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kb.toderu.ro\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kb.toderu.ro\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kb.toderu.ro\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kb.toderu.ro\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=37"}],"version-history":[{"count":0,"href":"https:\/\/kb.toderu.ro\/index.php?rest_route=\/wp\/v2\/posts\/37\/revisions"}],"wp:attachment":[{"href":"https:\/\/kb.toderu.ro\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=37"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kb.toderu.ro\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=37"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kb.toderu.ro\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=37"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}