<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="/stylesheets/rss.css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>David's Computer Stuff Journal: Process creation monitoring</title>
    <link>http://journal.dedasys.com/articles/2007/08/06/process-creation-monitoring</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description></description>
    <item>
      <title>Process creation monitoring</title>
      <description>&lt;p&gt;So, I'm stumped - maybe someone knows the answer to this one.  I noticed that on my new Ubuntu system, if I ran &lt;code&gt;ps&lt;/code&gt; every 5 seconds or so, the process number jumped significantly, by 5 or 6.  Being a bit of a control freak, I want to know exactly what's creating those processes, so I wrote a little Tcl script to try and catch any new [0-9]* directories in proc and read its &lt;code&gt;cmdline&lt;/code&gt; file entry, but that seems to not be fast enough to catch the culprit in the act.  I had a look at inotify, but that doesn't seem to work with /proc.  So at this point, I'm stumped, and am looking around for suggestions.  I just want to have a record of newly created processes... seems like it ought to be possible.&lt;/p&gt;</description>
      <pubDate>Mon, 06 Aug 2007 02:53:00 -0700</pubDate>
      <guid isPermaLink="false">urn:uuid:00e83755-c434-4e13-9030-c2fa07258c50</guid>
      <author>David N. Welton</author>
      <link>http://journal.dedasys.com/articles/2007/08/06/process-creation-monitoring</link>
      <trackback:ping>http://journal.dedasys.com/articles/trackback/1799</trackback:ping>
    </item>
    <item>
      <title>"Process creation monitoring" by Beno&#238;t Dejean</title>
      <description>&lt;p&gt;&lt;a href="http://bugzilla.gnome.org/show_bug.cgi?id=439930" rel="nofollow"&gt;http://bugzilla.gnome.org/show_bug.cgi?id=439930&lt;/a&gt;&lt;/p&gt;</description>
      <pubDate>Tue, 07 Aug 2007 18:02:38 -0700</pubDate>
      <guid isPermaLink="false">urn:uuid:aeb3c887-ac38-4979-b672-156f42bf9c5a</guid>
      <link>http://journal.dedasys.com/articles/2007/08/06/process-creation-monitoring#comment-287</link>
    </item>
    <item>
      <title>"Process creation monitoring" by Stuart Yeates</title>
      <description>&lt;p&gt;What are your cron settings? &lt;/p&gt;

&lt;p&gt;I log authentication, so my logs are full of cron waking up, shedding previledges, forking a process to check whether any jobs need running, finding that none are, and exiting.&lt;/p&gt;</description>
      <pubDate>Tue, 07 Aug 2007 09:02:02 -0700</pubDate>
      <guid isPermaLink="false">urn:uuid:64ecd3a5-b5a2-457c-abbd-ebde583ac06f</guid>
      <link>http://journal.dedasys.com/articles/2007/08/06/process-creation-monitoring#comment-286</link>
    </item>
    <item>
      <title>"Process creation monitoring" by Steve</title>
      <description>&lt;p&gt;You can log all processes with snoopy:&lt;/p&gt;

&lt;p&gt;&lt;a href="http://www.debian-administration.org/articles/88" rel="nofollow"&gt;http://www.debian-administration.org/articles/88&lt;/a&gt;&lt;/p&gt;</description>
      <pubDate>Mon, 06 Aug 2007 15:36:26 -0700</pubDate>
      <guid isPermaLink="false">urn:uuid:4cdfdb3e-9f65-413e-ac05-2e6c07be0153</guid>
      <link>http://journal.dedasys.com/articles/2007/08/06/process-creation-monitoring#comment-284</link>
    </item>
    <item>
      <title>"Process creation monitoring" by Dave Welton</title>
      <description>&lt;p&gt;And the gnome cups thing is spawning threads in order to do some HTTP calls to cups without blocking, apparently.  Didn't think it was anything important, but it's sort of annoying all the same.&lt;/p&gt;</description>
      <pubDate>Mon, 06 Aug 2007 07:41:33 -0700</pubDate>
      <guid isPermaLink="false">urn:uuid:ec8370af-288a-4256-8046-845501b2b419</guid>
      <link>http://journal.dedasys.com/articles/2007/08/06/process-creation-monitoring#comment-283</link>
    </item>
    <item>
      <title>"Process creation monitoring" by Dave Welton</title>
      <description>&lt;p&gt;Ok, the solution!&lt;/p&gt;

&lt;p&gt;I looked at how ps -eLF was doing things, and modified my Tcl code accordingly:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;proc main {} {
    set glob {/proc/*/task/[0-9]*}

    set procs [lsort [glob $glob]]

    while {1} {
        set newprocs [lsort [glob $glob]]
        if { [llength $procs] != [llength $newprocs] } {
            foreach i $newprocs j $procs {
                if { $i != $j} {
                    puts "New process $i"
                    set fl [open "$i/cmdline"]
                    set data [read $fl]
                    close $fl
                    puts "cmdline: $data"
                    break
                }
            }
        }
        set procs $newprocs
    }
}

main
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;It's quick and dirty, compared with something like systemtap, but requires no kernel recompile or modifications, and was able to find the culprit:&lt;/p&gt;

&lt;p&gt;gnome-cups-icon--sm-client-iddefault3&lt;/p&gt;

&lt;p&gt;Now, I wonder why that's spawning so many threads?&lt;/p&gt;</description>
      <pubDate>Mon, 06 Aug 2007 07:21:17 -0700</pubDate>
      <guid isPermaLink="false">urn:uuid:fd65f2c1-6ccc-40fc-b399-76dec5f445a2</guid>
      <link>http://journal.dedasys.com/articles/2007/08/06/process-creation-monitoring#comment-282</link>
    </item>
    <item>
      <title>"Process creation monitoring" by Dave Welton</title>
      <description>&lt;p&gt;accttail doesn't do the job, because it's looking at processes, and I think the posters focusing on threads are on the right trail.  The only process I can find doing anything is postgresql doing some cleanups, but even turning that off, I get the mystery threads...&lt;/p&gt;

&lt;p&gt;Even so, thanks for pointing it out - it's a neat program that I'll keep in mind for the future.&lt;/p&gt;</description>
      <pubDate>Mon, 06 Aug 2007 06:58:49 -0700</pubDate>
      <guid isPermaLink="false">urn:uuid:86f990e5-d646-49a8-a8cb-2f3557a15a01</guid>
      <link>http://journal.dedasys.com/articles/2007/08/06/process-creation-monitoring#comment-281</link>
    </item>
    <item>
      <title>"Process creation monitoring" by David</title>
      <description>&lt;p&gt;The connector reports process events to userspace. It uses the netlink mechanism and your kernel must be built with the following configuration options:&lt;/p&gt;

&lt;p&gt;Device Drivers ---&gt;&lt;/p&gt;

&lt;p&gt;Connector - unified userspace&amp;lt;-&gt;kernelspace linker ---&gt;&lt;/p&gt;

&lt;p&gt;&amp;lt;*&gt; Connector unified userspace &amp;lt;-&gt; kernelspace linker
[*]   Report process events to userspace&lt;/p&gt;

&lt;p&gt;This option is available since 2.6.15.&lt;/p&gt;</description>
      <pubDate>Mon, 06 Aug 2007 06:19:54 -0700</pubDate>
      <guid isPermaLink="false">urn:uuid:1f8a9a0d-6c71-4c81-9eff-6074a0ab0d2e</guid>
      <link>http://journal.dedasys.com/articles/2007/08/06/process-creation-monitoring#comment-279</link>
    </item>
    <item>
      <title>"Process creation monitoring" by folkert@vanheusden.com</title>
      <description>&lt;p&gt;easy.
'acctail' will give you this information nicely. URL: &lt;a href="http://www.vanheusden.com/acctail/" rel="nofollow"&gt;http://www.vanheusden.com/acctail/&lt;/a&gt;
it uses the bsd process accounting facility &lt;/p&gt;</description>
      <pubDate>Mon, 06 Aug 2007 04:50:24 -0700</pubDate>
      <guid isPermaLink="false">urn:uuid:70d54fd8-5167-40d7-b87e-81eb0e599ddb</guid>
      <link>http://journal.dedasys.com/articles/2007/08/06/process-creation-monitoring#comment-278</link>
    </item>
    <item>
      <title>"Process creation monitoring" by Arvin</title>
      <description>&lt;p&gt;Hi,&lt;/p&gt;

&lt;p&gt;You could also try the BSD process accounting facility of the linux kernel (General Setup-&gt;BSD Process Accounting) and install the "acct" debian package.&lt;/p&gt;</description>
      <pubDate>Mon, 06 Aug 2007 03:53:36 -0700</pubDate>
      <guid isPermaLink="false">urn:uuid:7b9f30cc-4b64-4da2-afd3-00fc52802491</guid>
      <link>http://journal.dedasys.com/articles/2007/08/06/process-creation-monitoring#comment-277</link>
    </item>
    <item>
      <title>"Process creation monitoring" by Adam</title>
      <description>&lt;p&gt;What if you do a "ps" every 10 seconds or so? Does the process number jump by 10 or 12, or still just by 5 or 6?&lt;/p&gt;

&lt;p&gt;If it's still just 5 or 6, then the short-lived processes might be a consequence of running "ps". Not sure why, but it's a possibility. Try running "strace" on your shell as you launch "ps" to see what happens, or "ps" under "strace". "strace" has options to have it only display fork/exec type calls to cut the output down to something manageable.&lt;/p&gt;

&lt;p&gt;Alternatively, write a script to keep "ps"ing in a loop and store the output of each in a file. You'll probably catch one of them after a while as a process that shows up in only one ps list.&lt;/p&gt;</description>
      <pubDate>Mon, 06 Aug 2007 03:49:08 -0700</pubDate>
      <guid isPermaLink="false">urn:uuid:96d2382b-1706-405f-b0eb-13af6bb29424</guid>
      <link>http://journal.dedasys.com/articles/2007/08/06/process-creation-monitoring#comment-276</link>
    </item>
    <item>
      <title>"Process creation monitoring" by mla@lausch.at</title>
      <description>&lt;p&gt;Each new thread, not only processes increments the PID. use "ps -eLf" to look at the threads(LWP) in a process. you don't find them in /proc. A multithreaded program example:&lt;/p&gt;

&lt;p&gt;"ps -eLf" returns 
6564 as the PID and 6565-6580 as LWPs for this pid&lt;/p&gt;

&lt;p&gt;"ls /proc | grep 6565" returns nothing, but "ls /proc/6565" prints the directory listing for this LWP. This means the /proc directory entries are fake and created on demand. Use systemtop as Mikael Olen suggested to instrument exec/clone calls in the kernel. &lt;/p&gt;</description>
      <pubDate>Mon, 06 Aug 2007 03:37:39 -0700</pubDate>
      <guid isPermaLink="false">urn:uuid:a4e2ba13-519b-4296-a442-94090f4f613a</guid>
      <link>http://journal.dedasys.com/articles/2007/08/06/process-creation-monitoring#comment-275</link>
    </item>
    <item>
      <title>"Process creation monitoring" by Mark Brown</title>
      <description>&lt;p&gt;There are some kernel patches people have been trying to integrate recently to provide this sort of instrumentation. You really do need kernel support to close the races with short lived processes.&lt;/p&gt;

&lt;p&gt;If you have some idea which process is creating new processes you could try ptrace, I expect...&lt;/p&gt;</description>
      <pubDate>Mon, 06 Aug 2007 03:30:08 -0700</pubDate>
      <guid isPermaLink="false">urn:uuid:27bbbd81-7a76-4169-9378-1822b9ade91c</guid>
      <link>http://journal.dedasys.com/articles/2007/08/06/process-creation-monitoring#comment-274</link>
    </item>
    <item>
      <title>"Process creation monitoring" by Mikael Olen falk</title>
      <description>&lt;p&gt;You could try getting the info with systemtap &lt;a href="http://sourceware.org/systemtap/" rel="nofollow"&gt;http://sourceware.org/systemtap/&lt;/a&gt;&lt;/p&gt;</description>
      <pubDate>Mon, 06 Aug 2007 03:21:18 -0700</pubDate>
      <guid isPermaLink="false">urn:uuid:db558b5d-edff-4f14-a8dc-74a5b5815259</guid>
      <link>http://journal.dedasys.com/articles/2007/08/06/process-creation-monitoring#comment-273</link>
    </item>
  </channel>
</rss>
