<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Killing parent pid in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/killing-parent-pid/m-p/4497816#M364477</link>
    <description>Hi Srini:&lt;BR /&gt;&lt;BR /&gt;&amp;gt; ...replace echo with kill&lt;BR /&gt;&lt;BR /&gt;And while we are on the subject of killing processes, don't use 'kill -9' without first attempting a simple 'kill' first.&lt;BR /&gt;&lt;BR /&gt;A 'kill -9' cannot be caught and thus a process has no (programatic) chance to cleanup temporary files and/or shared memory segments.&lt;BR /&gt;&lt;BR /&gt;Instead, escalate your annihilation:&lt;BR /&gt;&lt;BR /&gt;kill -TERM ${mypid} &amp;gt; /dev/null 2&amp;gt;&amp;amp;1&lt;BR /&gt;sleep 2&lt;BR /&gt;kill -HUP  ${mypid} &amp;gt; /dev/null 2&amp;gt;&amp;amp;1&lt;BR /&gt;sleep 2&lt;BR /&gt;kill -9    ${mypid} &amp;gt; /dev/null 2&amp;gt;&amp;amp;1&lt;BR /&gt;&lt;BR /&gt;If the first 'kill' works ${mypid} will no longer be valid and the second (and third) 'kill's will be no-ops.  If the 'kill -9' fails to terminate the process then it is waiting on an I/O to complete or in some other kernel state for which it can't be interrupted.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
    <pubDate>Thu, 17 Sep 2009 20:04:28 GMT</pubDate>
    <dc:creator>James R. Ferguson</dc:creator>
    <dc:date>2009-09-17T20:04:28Z</dc:date>
    <item>
      <title>Killing parent pid</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/killing-parent-pid/m-p/4497806#M364467</link>
      <description>Will killing the parent pid kills all its child process?&lt;BR /&gt;user1  3870  1667  1  Sep  9  ?         4:52 b&lt;BR /&gt;user1  3871  1667  0  Sep  9  ?         4:50 c&lt;BR /&gt;user1  3878  1667  0  Sep  9  ?         4:49 d&lt;BR /&gt;user1  1667     1  0  Sep  9  ?        12:33 a&lt;BR /&gt;user1  3868  1667  0  Sep  9  ?         4:44 e&lt;BR /&gt;&lt;BR /&gt;a is the parent process and b,c,d,e are the child processes.&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Srini</description>
      <pubDate>Tue, 15 Sep 2009 12:46:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/killing-parent-pid/m-p/4497806#M364467</guid>
      <dc:creator>Srinikalyan</dc:creator>
      <dc:date>2009-09-15T12:46:53Z</dc:date>
    </item>
    <item>
      <title>Re: Killing parent pid</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/killing-parent-pid/m-p/4497807#M364468</link>
      <description>It depends. If the software was written in a way to clean up properly, yes, the child processes should be killed when  the parent process dies. But the software might be written deliberately (or sometimes accidentally or even in a sloppy way) not to do this, i.e., the child processes live after the parent dies being owned by a PPID of 1.&lt;BR /&gt;&lt;BR /&gt;It all depends on the software and there is no definite answer as I know of.</description>
      <pubDate>Tue, 15 Sep 2009 12:53:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/killing-parent-pid/m-p/4497807#M364468</guid>
      <dc:creator>Mel Burslan</dc:creator>
      <dc:date>2009-09-15T12:53:42Z</dc:date>
    </item>
    <item>
      <title>Re: Killing parent pid</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/killing-parent-pid/m-p/4497808#M364469</link>
      <description>Is there any script to find all the child processes if we give the input as the parent pid?</description>
      <pubDate>Tue, 15 Sep 2009 13:19:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/killing-parent-pid/m-p/4497808#M364469</guid>
      <dc:creator>Srinikalyan</dc:creator>
      <dc:date>2009-09-15T13:19:27Z</dc:date>
    </item>
    <item>
      <title>Re: Killing parent pid</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/killing-parent-pid/m-p/4497809#M364470</link>
      <description>simple..&lt;BR /&gt;&lt;BR /&gt;PPID=whatever&lt;BR /&gt;ps -ef | awk {'print $3'} | grep $PPID</description>
      <pubDate>Tue, 15 Sep 2009 13:33:02 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/killing-parent-pid/m-p/4497809#M364470</guid>
      <dc:creator>Mel Burslan</dc:creator>
      <dc:date>2009-09-15T13:33:02Z</dc:date>
    </item>
    <item>
      <title>Re: Killing parent pid</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/killing-parent-pid/m-p/4497810#M364471</link>
      <description>sorry the command I gave will not produce any output you deserve but this should:&lt;BR /&gt;&lt;BR /&gt;PPID=whatever&lt;BR /&gt;ps -ef | grep $PPID&lt;BR /&gt;&lt;BR /&gt;this output will also include a line for the parent process as well as all the child processes&lt;BR /&gt;</description>
      <pubDate>Tue, 15 Sep 2009 13:37:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/killing-parent-pid/m-p/4497810#M364471</guid>
      <dc:creator>Mel Burslan</dc:creator>
      <dc:date>2009-09-15T13:37:28Z</dc:date>
    </item>
    <item>
      <title>Re: Killing parent pid</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/killing-parent-pid/m-p/4497811#M364472</link>
      <description>&amp;gt; Is there any script to find all the child processes if we give the input as the parent pid?&lt;BR /&gt; &lt;BR /&gt;The ps command can show the entire hierarchy:&lt;BR /&gt; &lt;BR /&gt;UNIX95=1 ps -eH&lt;BR /&gt;or&lt;BR /&gt;UNIX95=1 ps -efH&lt;BR /&gt; &lt;BR /&gt;Be sure to copy/paste the entire line. UNIX95=1 sets a special option for ps.&lt;BR /&gt; &lt;BR /&gt;But the best tool is pstree. Here's a link to it: &lt;A href="http://en.wikipedia.org/wiki/Pstree" target="_blank"&gt;http://en.wikipedia.org/wiki/Pstree&lt;/A&gt;&lt;BR /&gt; &lt;BR /&gt;pstree -p #####&lt;BR /&gt; &lt;BR /&gt;where ##### is any process in the tree. pstree will show the entire branch up and down.</description>
      <pubDate>Wed, 16 Sep 2009 02:14:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/killing-parent-pid/m-p/4497811#M364472</guid>
      <dc:creator>Bill Hassell</dc:creator>
      <dc:date>2009-09-16T02:14:26Z</dc:date>
    </item>
    <item>
      <title>Re: Killing parent pid</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/killing-parent-pid/m-p/4497812#M364473</link>
      <description>Hello Bill,&lt;BR /&gt;&lt;BR /&gt;In HP-UX 11.31 ptree exists and do the same as pstree.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Roland</description>
      <pubDate>Wed, 16 Sep 2009 05:56:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/killing-parent-pid/m-p/4497812#M364473</guid>
      <dc:creator>Roland Piette</dc:creator>
      <dc:date>2009-09-16T05:56:07Z</dc:date>
    </item>
    <item>
      <title>Re: Killing parent pid</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/killing-parent-pid/m-p/4497813#M364474</link>
      <description>&amp;gt;Mel: PPID=whatever; ps -ef | grep $PPID&lt;BR /&gt;&lt;BR /&gt;A safer command would be:&lt;BR /&gt;PPID=whatever&lt;BR /&gt;UNIX_95=EXTENDED_PS ps -ef -opid= -ocomm= -oppid= | grep " $PPID$"&lt;BR /&gt;&lt;BR /&gt;This makes sure you can search for PPID=1.</description>
      <pubDate>Wed, 16 Sep 2009 10:21:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/killing-parent-pid/m-p/4497813#M364474</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2009-09-16T10:21:14Z</dc:date>
    </item>
    <item>
      <title>Re: Killing parent pid</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/killing-parent-pid/m-p/4497814#M364475</link>
      <description>I finally wrote script like below. The script will first kill all the child of the ppid and then finally ppid itself.&lt;BR /&gt;&lt;BR /&gt;Script starts here:&lt;BR /&gt;ppid=`ps -ef|grep 'TWM -u'|grep -v grep|awk '{print $2}'`&lt;BR /&gt;if [ -z "$ppid" ]&lt;BR /&gt;   then&lt;BR /&gt;   echo "no parent TM process running"&lt;BR /&gt;   else&lt;BR /&gt; echo " Child processes are " &lt;BR /&gt;for child in `ps -ef|grep -w $ppid|grep -v grep|awk '{if($3!=1) {print $2}}'`&lt;BR /&gt; do&lt;BR /&gt;  echo $child&lt;BR /&gt; #replace echo with kill &lt;BR /&gt; done&lt;BR /&gt; echo "Parent TM is " $ppid   &lt;BR /&gt;&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Srini&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 17 Sep 2009 06:02:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/killing-parent-pid/m-p/4497814#M364475</guid>
      <dc:creator>Srinikalyan</dc:creator>
      <dc:date>2009-09-17T06:02:04Z</dc:date>
    </item>
    <item>
      <title>Re: Killing parent pid</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/killing-parent-pid/m-p/4497815#M364476</link>
      <description>Warning: grep and ps will almost always give you wrong answers!!!&lt;BR /&gt; &lt;BR /&gt;Always use ps to find processes by name, never grep. In your script, grep "TWM -u" may be unique but you can't depend on that. If you want to find all the TWM processes, use ps like this:&lt;BR /&gt; &lt;BR /&gt;UNIX95=1 ps -C TWM -o pid= -o args=&lt;BR /&gt; &lt;BR /&gt;This method ensures that grep will not find something else (like grep). Now if several copies of TWM are running and you want to select only the one with -u, then you can add grep to the result like this:&lt;BR /&gt; &lt;BR /&gt;UNIX95=1 ps -C TWM -o pid= -o args= | grep -- -u&lt;BR /&gt; &lt;BR /&gt;Be sure to use two dashes (grep --) to terminate the option processing and treat "-u" as a simple string.&lt;BR /&gt; &lt;BR /&gt;But most important, do NOT grep for pid or ppid!!! This will find critical processes that happen to have matching numbers in the run string. ALWAYS use ps -p for exact PID matches.&lt;BR /&gt;</description>
      <pubDate>Thu, 17 Sep 2009 18:41:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/killing-parent-pid/m-p/4497815#M364476</guid>
      <dc:creator>Bill Hassell</dc:creator>
      <dc:date>2009-09-17T18:41:14Z</dc:date>
    </item>
    <item>
      <title>Re: Killing parent pid</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/killing-parent-pid/m-p/4497816#M364477</link>
      <description>Hi Srini:&lt;BR /&gt;&lt;BR /&gt;&amp;gt; ...replace echo with kill&lt;BR /&gt;&lt;BR /&gt;And while we are on the subject of killing processes, don't use 'kill -9' without first attempting a simple 'kill' first.&lt;BR /&gt;&lt;BR /&gt;A 'kill -9' cannot be caught and thus a process has no (programatic) chance to cleanup temporary files and/or shared memory segments.&lt;BR /&gt;&lt;BR /&gt;Instead, escalate your annihilation:&lt;BR /&gt;&lt;BR /&gt;kill -TERM ${mypid} &amp;gt; /dev/null 2&amp;gt;&amp;amp;1&lt;BR /&gt;sleep 2&lt;BR /&gt;kill -HUP  ${mypid} &amp;gt; /dev/null 2&amp;gt;&amp;amp;1&lt;BR /&gt;sleep 2&lt;BR /&gt;kill -9    ${mypid} &amp;gt; /dev/null 2&amp;gt;&amp;amp;1&lt;BR /&gt;&lt;BR /&gt;If the first 'kill' works ${mypid} will no longer be valid and the second (and third) 'kill's will be no-ops.  If the 'kill -9' fails to terminate the process then it is waiting on an I/O to complete or in some other kernel state for which it can't be interrupted.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Thu, 17 Sep 2009 20:04:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/killing-parent-pid/m-p/4497816#M364477</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2009-09-17T20:04:28Z</dc:date>
    </item>
    <item>
      <title>Re: Killing parent pid</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/killing-parent-pid/m-p/4497817#M364478</link>
      <description>Srinikalyan,&lt;BR /&gt;&lt;BR /&gt;&amp;gt;Is there any script to find all the child processes if we give the input as the parent pid?&lt;BR /&gt;&lt;BR /&gt;Which version of OS you are using.&lt;BR /&gt;If you are on 11.31  use , ptree  , it is a very nice program. It prints the complete process tree hierarchy.&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://docs.hp.com/en/B2355-60130/ptree.1.html" target="_blank"&gt;http://docs.hp.com/en/B2355-60130/ptree.1.html&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Cheers,&lt;BR /&gt;Raj.</description>
      <pubDate>Thu, 17 Sep 2009 20:08:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/killing-parent-pid/m-p/4497817#M364478</guid>
      <dc:creator>Raj D.</dc:creator>
      <dc:date>2009-09-17T20:08:48Z</dc:date>
    </item>
    <item>
      <title>Re: Killing parent pid</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/killing-parent-pid/m-p/4497818#M364479</link>
      <description>&amp;gt;Bill:  grep -- -u  Be sure to use two dashes (grep --) to terminate the option processing and treat "-u" as a simple string.&lt;BR /&gt;&lt;BR /&gt;Using "--" is overkill and not as flexible as just "-e -u".  After -e, you can add more options.&lt;BR /&gt;&lt;BR /&gt;&amp;gt;do NOT grep for pid or ppid!!! This will find critical processes that happen to have matching numbers in the run string.&lt;BR /&gt;&lt;BR /&gt;My grep pattern anchored it to the PPID.</description>
      <pubDate>Fri, 18 Sep 2009 08:08:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/killing-parent-pid/m-p/4497818#M364479</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2009-09-18T08:08:42Z</dc:date>
    </item>
  </channel>
</rss>

