Professional Web Applications Themes

pkill oddity - Sun Solaris

I recently was bitten by an oddity with pkill, and I wonder if people would consider it a bug: While trying to restart sshd on a remote server, I issued the following: $ ptree 4315 /usr/local/sbin/sshd 5375 /usr/local/sbin/sshd 5378 -ksh 5388 ptree 5378 $ pgrep -P 1 sshd 4315 $ su root -c 'pkill -9 -P 1 sshd' Password: and at this point, I got logged off. Here's what I think happens: if pkill find the parent before it finds the child, it kills the parent first. This makes the child an orphan, and when it is examined later, it ...

  1. #1

    Default pkill oddity

    I recently was bitten by an oddity with pkill, and I wonder if
    people would consider it a bug:

    While trying to restart sshd on a remote server, I issued the
    following:

    $ ptree
    4315 /usr/local/sbin/sshd
    5375 /usr/local/sbin/sshd
    5378 -ksh
    5388 ptree 5378
    $ pgrep -P 1 sshd
    4315
    $ su root -c 'pkill -9 -P 1 sshd'
    Password:

    and at this point, I got logged off.

    Here's what I think happens: if pkill find the parent before
    it finds the child, it kills the parent first. This makes the
    child an orphan, and when it is examined later, it then has a
    PPID of 1, so it is terminated, too.

    It would seem more reasonable, given that its purpose is to
    terminate processes, for pkill to scan first and then kill
    based on what it finds. As it stands now, its action is
    indeterminate.

    I guess I'll have to start using "kill -9 $(pgrep ...)"

    What do other people think?

    Rob
    Rob Guest

  2. #2

    Default Re: pkill oddity

    com (Rob Stampfli) writes:
     
     
     
     

    Surprise!
     

    I think you should have used

    su root -c 'kill -HUP `cat /var/run/sshd.pid`'

    At the very least, if you had use "-HUP" (or -1) in place
    of "-9", you would have been able to ssh back in.

    Using "kill -9" is a bad habit. It should be reserved for
    cases where all else fails.

    -------

    Footnote: I am considering a change to running sshd via inetd.conf
    That way it won't need to be restarted.

    Neil Guest

  3. #3

    Default Re: pkill oddity

    In article <RW%fb.24953$news.prodigy.com>,
    Neil W Rickert <rickert+niu.edu> wrote: 

    The one negative to this approach is that sshd has to generate an
    internal server key during its initialization phase, and this can
    take some time, depending on processor speed and load. Normally,
    this key is regenerated in the background hourly, but sshd won't
    allow the login sequence to commence before the key is available,
    and it must, of course, initialize itself every time it is spawned
    anew from inetd.

    Rob
    Rob Guest

  4. #4

    Default Re: pkill oddity

    On Mon, 06 Oct 2003 02:12:29 GMT, Rob Stampfli said something similar to:
    : In article <RW%fb.24953$news.prodigy.com>,
    : Neil W Rickert <rickert+niu.edu> wrote:
    : >
    : >Footnote: I am considering a change to running sshd via inetd.conf
    : >That way it won't need to be restarted.
    : >
    :
    : The one negative to this approach is that sshd has to generate an
    : internal server key during its initialization phase, and this can
    : take some time, depending on processor speed and load. Normally,
    : this key is regenerated in the background hourly, but sshd won't
    : allow the login sequence to commence before the key is available,
    : and it must, of course, initialize itself every time it is spawned
    : anew from inetd.

    I'm reasonably sure this is the case only for protocol v1. Version 2 of
    the SSH protocol uses (IIRC) Diffie-Helman rather than an "ephemeral"
    server public key to perform the session key exchange. I don't believe
    there's a major performance issue with running a SSHv2 only sshd through
    inetd (however, I haven't personally tried it either, so YMMV).

    Mike Guest

Similar Threads

  1. Date oddity in Acrobat, default page size oddity
    By Matt_Nelson@adobeforums.com in forum Adobe Acrobat Macintosh
    Replies: 3
    Last Post: November 14th, 03:35 PM
  2. image oddity
    By Word in forum Macromedia Director Lingo
    Replies: 7
    Last Post: December 23rd, 12:53 PM
  3. OE oddity
    By Dunphy in forum Windows XP/2000/ME
    Replies: 1
    Last Post: July 10th, 11:55 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139