<?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: Proper Kill in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/proper-kill/m-p/2650308#M45877</link>
    <description>Hi Ted:&lt;BR /&gt;&lt;BR /&gt;Sorry, that should read: "Thus, the user *cannot* strike the CNTL_C key combination and break out of /etc/profile."&lt;BR /&gt;&lt;BR /&gt;Here's another simple example:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;typeset -i N&lt;BR /&gt;trap "echo killed!;exit 1" 15&lt;BR /&gt;echo $$&lt;BR /&gt;while (( N &amp;lt;= 30 ))&lt;BR /&gt;do&lt;BR /&gt;  let N=N+1&lt;BR /&gt;  date&lt;BR /&gt;  sleep 1&lt;BR /&gt;done&lt;BR /&gt;exit 0&lt;BR /&gt;&lt;BR /&gt;If you run this script, you see the process's pid echoed followed by 30 displays of the current time.  When it is running, if you do:&lt;BR /&gt;&lt;BR /&gt;# kill &lt;PID&gt;&lt;BR /&gt;&lt;BR /&gt;...or kill -15 &lt;PID&gt;&lt;BR /&gt;&lt;BR /&gt;...then the script will echo "killed!" and exit with a return code of &amp;lt;1&amp;gt;.&lt;BR /&gt;&lt;BR /&gt;The point is that you could do anything you wanted -- remove files, etc. etc.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF... &lt;BR /&gt;&lt;/PID&gt;&lt;/PID&gt;</description>
    <pubDate>Tue, 22 Jan 2002 21:12:15 GMT</pubDate>
    <dc:creator>James R. Ferguson</dc:creator>
    <dc:date>2002-01-22T21:12:15Z</dc:date>
    <item>
      <title>Proper Kill</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/proper-kill/m-p/2650299#M45868</link>
      <description>I was reading yesterday not to use a kill -9 because it doesnt clean up files.  This is the way that I was taught to kill.  What I do is ps -ef user, shutuser, then kill processes with a kill -9 "pid".  What is the correct way to do this?</description>
      <pubDate>Tue, 22 Jan 2002 19:31:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/proper-kill/m-p/2650299#M45868</guid>
      <dc:creator>Ted Flanders</dc:creator>
      <dc:date>2002-01-22T19:31:17Z</dc:date>
    </item>
    <item>
      <title>Re: Proper Kill</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/proper-kill/m-p/2650300#M45869</link>
      <description>try a 'kill &lt;PROCESSID&gt;'  or if you are drawn the the kill with a number option, 'kill -6 &lt;PROCESSID&gt;'  A good rule of thumb is to try this a couple of times before resorting to stomping on it with a 'kill -9'...  This should allow the process to hangup before it exits.&lt;BR /&gt;&lt;BR /&gt;Have fun.&lt;BR /&gt;&lt;BR /&gt;John&lt;/PROCESSID&gt;&lt;/PROCESSID&gt;</description>
      <pubDate>Tue, 22 Jan 2002 19:35:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/proper-kill/m-p/2650300#M45869</guid>
      <dc:creator>John Payne_2</dc:creator>
      <dc:date>2002-01-22T19:35:59Z</dc:date>
    </item>
    <item>
      <title>Re: Proper Kill</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/proper-kill/m-p/2650301#M45870</link>
      <description>Hi Ted,&lt;BR /&gt;&lt;BR /&gt;I won't say that kill -9 is always bad, it simply should be the weapon of last resort because of the cleanup issue that you mentioned.&lt;BR /&gt;&lt;BR /&gt;My way is&lt;BR /&gt;kill -15 $pid&lt;BR /&gt;kill -1 $pid&lt;BR /&gt;kill -2 $pid&lt;BR /&gt;kill -3 $pid&lt;BR /&gt;kill -11 $pid.&lt;BR /&gt;&lt;BR /&gt;Kill -11 will clobber almost as well as kill -9 and can be caught and thus cleanup can be done. Only when the above are exhausted and you really need to kill something should you then bring out the big hammer, kill -9. A good technique is to send kill -0 $pid after each attempt to see if the pid is still valid and thus the process is still out there. &lt;BR /&gt;&lt;BR /&gt;Regards, Clay</description>
      <pubDate>Tue, 22 Jan 2002 19:37:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/proper-kill/m-p/2650301#M45870</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2002-01-22T19:37:08Z</dc:date>
    </item>
    <item>
      <title>Re: Proper Kill</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/proper-kill/m-p/2650302#M45871</link>
      <description>Hi:&lt;BR /&gt;&lt;BR /&gt;A 'kill -9' can't be trapped and therefore doesn't give the recipient any chance to cleanup files and/or shared memory.&lt;BR /&gt;&lt;BR /&gt;It is far cleaner to issue a simple 'kill' (kill -15) or a kill -1 (kill -hup) *first*; wait a few seconds; and then as a last resort, if necessary, issue a kill -9.&lt;BR /&gt;&lt;BR /&gt;Remember that zombies or processes hung waiting on an IO are *not* going to vanish even with a 'kill -9'.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Tue, 22 Jan 2002 19:38:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/proper-kill/m-p/2650302#M45871</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2002-01-22T19:38:19Z</dc:date>
    </item>
    <item>
      <title>Re: Proper Kill</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/proper-kill/m-p/2650303#M45872</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;Kill -11 is equivalent to -9 but it cleans up..&lt;BR /&gt;-USA..</description>
      <pubDate>Tue, 22 Jan 2002 19:40:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/proper-kill/m-p/2650303#M45872</guid>
      <dc:creator>Uday_S_Ankolekar</dc:creator>
      <dc:date>2002-01-22T19:40:04Z</dc:date>
    </item>
    <item>
      <title>Re: Proper Kill</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/proper-kill/m-p/2650304#M45873</link>
      <description>Ted,&lt;BR /&gt;&lt;BR /&gt;Another good rule of thumb, is to get the "lsof" command from:&lt;BR /&gt;&lt;A href="http://hpux.cs.utah.edu/hppd/hpux/Sysadmin/lsof-4.55/" target="_blank"&gt;http://hpux.cs.utah.edu/hppd/hpux/Sysadmin/lsof-4.55/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;and use this to determine what files a process has open, because the last thing you want to be doing is clobbering a process that is updating files.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;live free or die&lt;BR /&gt;harry</description>
      <pubDate>Tue, 22 Jan 2002 19:43:22 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/proper-kill/m-p/2650304#M45873</guid>
      <dc:creator>harry d brown jr</dc:creator>
      <dc:date>2002-01-22T19:43:22Z</dc:date>
    </item>
    <item>
      <title>Re: Proper Kill</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/proper-kill/m-p/2650305#M45874</link>
      <description>Hi Ted,&lt;BR /&gt;&lt;BR /&gt;kill -9 is nasty and should be used as a last resort.  It is most likely able to kill the process (processes hanging on an I/O request appear immune to -9) but it is the equivilant or cracking a nut with a sledge hammer.  You just don't know what damage you may be doing to your application.&lt;BR /&gt;&lt;BR /&gt;Always, always try kill -15 first.&lt;BR /&gt;&lt;BR /&gt;Darrell</description>
      <pubDate>Tue, 22 Jan 2002 19:57:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/proper-kill/m-p/2650305#M45874</guid>
      <dc:creator>Darrell Allen</dc:creator>
      <dc:date>2002-01-22T19:57:18Z</dc:date>
    </item>
    <item>
      <title>Re: Proper Kill</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/proper-kill/m-p/2650306#M45875</link>
      <description>Ok........so what do you mean that it "cleans up" or "traps" or can be "caught"?  Sorry to ask, but if I dont, I will never know. "A kill -9 cant be Trapped and therefore doesnt give the recipient time to cleanup files or shared memory."  I am a little confused by this.  When I kill someone it is usually because they are locked up and cant do anything.  How would they be able to cleanup files in this case?</description>
      <pubDate>Tue, 22 Jan 2002 20:39:21 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/proper-kill/m-p/2650306#M45875</guid>
      <dc:creator>Ted Flanders</dc:creator>
      <dc:date>2002-01-22T20:39:21Z</dc:date>
    </item>
    <item>
      <title>Re: Proper Kill</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/proper-kill/m-p/2650307#M45876</link>
      <description>Hi (again) Ted:&lt;BR /&gt;&lt;BR /&gt;A signal can be "trapped" (or "caught").  A trap is an interrupt handler.  When a signal is received, an interrupt is executed.  That is, a 'jump' to an interrupt (trap) routine is made and any code associated with the trap is executed.&lt;BR /&gt;&lt;BR /&gt;If you look at /etc/profile, you wiil see a classic trap at the beginning:&lt;BR /&gt;&lt;BR /&gt;trap "" 1 2 3&lt;BR /&gt;&lt;BR /&gt;This says, "do nothing" (as denoted by the empty command ("")) upon receipt of signals 1 or 2 or 3 (hup, int, quit).  Thus, the user can stike the CNTL_C key combination and break out of /etc/profile.&lt;BR /&gt;&lt;BR /&gt;At the very end of /etc/profile you see:&lt;BR /&gt;&lt;BR /&gt;trap 1 2 3 &lt;BR /&gt;&lt;BR /&gt;This restores the signals hup, int and quit.&lt;BR /&gt;&lt;BR /&gt;For more information, have a look at the man pages for 'kill' and 'signal'.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Tue, 22 Jan 2002 20:59:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/proper-kill/m-p/2650307#M45876</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2002-01-22T20:59:40Z</dc:date>
    </item>
    <item>
      <title>Re: Proper Kill</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/proper-kill/m-p/2650308#M45877</link>
      <description>Hi Ted:&lt;BR /&gt;&lt;BR /&gt;Sorry, that should read: "Thus, the user *cannot* strike the CNTL_C key combination and break out of /etc/profile."&lt;BR /&gt;&lt;BR /&gt;Here's another simple example:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;typeset -i N&lt;BR /&gt;trap "echo killed!;exit 1" 15&lt;BR /&gt;echo $$&lt;BR /&gt;while (( N &amp;lt;= 30 ))&lt;BR /&gt;do&lt;BR /&gt;  let N=N+1&lt;BR /&gt;  date&lt;BR /&gt;  sleep 1&lt;BR /&gt;done&lt;BR /&gt;exit 0&lt;BR /&gt;&lt;BR /&gt;If you run this script, you see the process's pid echoed followed by 30 displays of the current time.  When it is running, if you do:&lt;BR /&gt;&lt;BR /&gt;# kill &lt;PID&gt;&lt;BR /&gt;&lt;BR /&gt;...or kill -15 &lt;PID&gt;&lt;BR /&gt;&lt;BR /&gt;...then the script will echo "killed!" and exit with a return code of &amp;lt;1&amp;gt;.&lt;BR /&gt;&lt;BR /&gt;The point is that you could do anything you wanted -- remove files, etc. etc.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF... &lt;BR /&gt;&lt;/PID&gt;&lt;/PID&gt;</description>
      <pubDate>Tue, 22 Jan 2002 21:12:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/proper-kill/m-p/2650308#M45877</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2002-01-22T21:12:15Z</dc:date>
    </item>
    <item>
      <title>Re: Proper Kill</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/proper-kill/m-p/2650309#M45878</link>
      <description>Hi again,&lt;BR /&gt;&lt;BR /&gt;Certain signals can be trapped - meaning the process will branch to a section of code to perform some other processing.  This could be things like rolling back an update, deleting temp files, or verifying the integrity of the data it was processing.  The process could also be written to simply ignore the signal and it could be written with different sections of code for different signals.&lt;BR /&gt;&lt;BR /&gt;A signal that can not be trapped means the process can not do any special processing based on that signal.  In the case of -9 the process is killed without regard for whatever it was doing at the time.  You can probably guess that it's not a good thing to do, particularly with something like a database or OnLine Transaction Process.&lt;BR /&gt;&lt;BR /&gt;A real life example would be making a withdrawal from an ATM.  If the order is to debit my account then dispense my money, I'd defintely be unhappy if that process was killed with a -9 after the debit was made but before the money was spit out.&lt;BR /&gt;&lt;BR /&gt;Darrell</description>
      <pubDate>Tue, 22 Jan 2002 21:23:31 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/proper-kill/m-p/2650309#M45878</guid>
      <dc:creator>Darrell Allen</dc:creator>
      <dc:date>2002-01-22T21:23:31Z</dc:date>
    </item>
    <item>
      <title>Re: Proper Kill</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/proper-kill/m-p/2650310#M45879</link>
      <description>Hi Ted:&lt;BR /&gt;&lt;BR /&gt;To amplify what Jim has said and to make it even more general, SIGKILL (kill -9) can't be caught. This applies not only to the shell using 'trap' but to any process. Most well behaved executables use either default signal handlers or custom signal handlers to handle&lt;BR /&gt;events. If you really want to know how this stuff works at the 'molecular' level then you should study the man (2) pages for signal and kill and the (3C) pages for setjmp and longjmp. If you grasp it at this level then you will absolutely nail it at the shell script level. For the 'atomic' level, you need to look at kernel internals but that's beyond the scope of this course.&lt;BR /&gt;&lt;BR /&gt;Food for thought, Clay</description>
      <pubDate>Tue, 22 Jan 2002 21:28:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/proper-kill/m-p/2650310#M45879</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2002-01-22T21:28:55Z</dc:date>
    </item>
    <item>
      <title>Re: Proper Kill</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/proper-kill/m-p/2650311#M45880</link>
      <description>Hi Ted,&lt;BR /&gt;I do not know exactly what the problem is,but as i understood from your message that you try to kill a procces but it keeps running after teh kill command.If that is the case ,have tried to kill the procces's parrent procces?&lt;BR /&gt;As far as i know if a procces comes back running whis different ID no. after each kill,&lt;BR /&gt;then it has parrent procces.&lt;BR /&gt;Regards.&lt;BR /&gt;</description>
      <pubDate>Wed, 23 Jan 2002 13:04:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/proper-kill/m-p/2650311#M45880</guid>
      <dc:creator>gimini</dc:creator>
      <dc:date>2002-01-23T13:04:26Z</dc:date>
    </item>
  </channel>
</rss>

