[Q] Bug in Process.kill on win32?

Discussion in 'Ruby' started by Laurent Julliard, Nov 18, 2004.

  1. I'm having serious troubles with Process.kill on 1.8.2 preview2 or
    1.8.1. Whenever I try to issue a Process.kill(sig,pid) there is an
    exception raised:

    in kill: invalid argument (Errno::EINVAL)

    I looked at the source code (rb_f_kill in signal.c) and it is *not* an
    error that relates to the sig and pid arguments which are OK but it
    looks like this is an error returned by the kill system call on Windows

    Any idea why this doesn't work? (I'm using the Ruby one-click
    installer compiled with VS C++ 7)

    Thanks for your help

    Laurent
    Laurent Julliard, Nov 18, 2004
    #1
    1. Advertising

  2. Laurent Julliard <> wrote in message news:<>...
    > I'm having serious troubles with Process.kill on 1.8.2 preview2 or
    > 1.8.1. Whenever I try to issue a Process.kill(sig,pid) there is an
    > exception raised:
    >
    > in kill: invalid argument (Errno::EINVAL)
    >
    > I looked at the source code (rb_f_kill in signal.c) and it is *not* an
    > error that relates to the sig and pid arguments which are OK but it
    > looks like this is an error returned by the kill system call on Windows
    >
    > Any idea why this doesn't work? (I'm using the Ruby one-click
    > installer compiled with VS C++ 7)
    >
    > Thanks for your help
    >
    > Laurent


    You're looking in the wrong place. Take a look at win32.c, which is
    where Process.kill is defined for Win32. The only named signals it
    understands are SIGINT and SIGKILL. It looks like any other value
    returns Errno::EINVAL. Not a great implementation IMHO.

    Note that win32-process includes a nicer version of Process.kill.

    Regards,

    Dan
    Daniel Berger, Nov 18, 2004
    #2
    1. Advertising

  3. Daniel Berger wrote:
    > Laurent Julliard <> wrote in message news:<>...
    >
    >>I'm having serious troubles with Process.kill on 1.8.2 preview2 or
    >>1.8.1. Whenever I try to issue a Process.kill(sig,pid) there is an
    >>exception raised:
    >>
    >>in kill: invalid argument (Errno::EINVAL)
    >>
    >>I looked at the source code (rb_f_kill in signal.c) and it is *not* an
    >>error that relates to the sig and pid arguments which are OK but it
    >>looks like this is an error returned by the kill system call on Windows
    >>
    >>Any idea why this doesn't work? (I'm using the Ruby one-click
    >>installer compiled with VS C++ 7)
    >>
    >>Thanks for your help
    >>
    >>Laurent

    >
    >
    > You're looking in the wrong place. Take a look at win32.c, which is
    > where Process.kill is defined for Win32. The only named signals it
    > understands are SIGINT and SIGKILL. It looks like any other value
    > returns Errno::EINVAL. Not a great implementation IMHO.
    >


    Well the point is that even when I use SIGINT (either using the string
    "SIGINT" or "INT" or the numeric value 2) it still gives the exact
    same error.

    > Note that win32-process includes a nicer version of Process.kill.
    >


    I have already downloaded this and I'm playing with it.

    Laurent


    --
    Laurent JULLIARD
    http://www.moldus.org/~laurent
    Laurent Julliard, Nov 18, 2004
    #3
  4. Laurent Julliard <> wrote in message news:<>...
    > Daniel Berger wrote:
    > > Laurent Julliard <> wrote in message news:<>...
    > >
    > >>I'm having serious troubles with Process.kill on 1.8.2 preview2 or
    > >>1.8.1. Whenever I try to issue a Process.kill(sig,pid) there is an
    > >>exception raised:
    > >>
    > >>in kill: invalid argument (Errno::EINVAL)
    > >>
    > >>I looked at the source code (rb_f_kill in signal.c) and it is *not* an
    > >>error that relates to the sig and pid arguments which are OK but it
    > >>looks like this is an error returned by the kill system call on Windows
    > >>
    > >>Any idea why this doesn't work? (I'm using the Ruby one-click
    > >>installer compiled with VS C++ 7)
    > >>
    > >>Thanks for your help
    > >>
    > >>Laurent

    > >
    > >
    > > You're looking in the wrong place. Take a look at win32.c, which is
    > > where Process.kill is defined for Win32. The only named signals it
    > > understands are SIGINT and SIGKILL. It looks like any other value
    > > returns Errno::EINVAL. Not a great implementation IMHO.
    > >

    >
    > Well the point is that even when I use SIGINT (either using the string
    > "SIGINT" or "INT" or the numeric value 2) it still gives the exact
    > same error.


    Ah, you are correct. That's a bug in the installer it looks like.
    Your other option is to build from source and see if you still see the
    same error.

    >
    > > Note that win32-process includes a nicer version of Process.kill.
    > >

    >
    > I have already downloaded this and I'm playing with it.
    >
    > Laurent


    I don't define SIGINT or SIGKILL in win32-process, but I could easily
    enough. Also note that SIGINT probably isn't going to work they way
    you think it should. This has to do with restrictions on sending
    signals to Windows processes, depenind on how those processes were
    created.

    However, I think I know how to make it work the way most folks would
    expect. I'll work on that in the coming weeks.

    Dan
    Daniel Berger, Nov 19, 2004
    #4
  5. Daniel Berger wrote:

    >>Well the point is that even when I use SIGINT (either using the string
    >>"SIGINT" or "INT" or the numeric value 2) it still gives the exact
    >>same error.

    >
    >
    > Ah, you are correct. That's a bug in the installer it looks like.
    > Your other option is to build from source and see if you still see the
    > same error.
    >


    Unfortunately I don't have Visual Studio available and cannot
    recompile. This being said I wouild really like to be able to fix this
    in the Ruby code. It must be an obvious bug in the win32.c file but I
    don't know the win32 interface well enough to see it


    >
    > I don't define SIGINT or SIGKILL in win32-process, but I could easily
    > enough. Also note that SIGINT probably isn't going to work they way
    > you think it should. This has to do with restrictions on sending
    > signals to Windows processes, depenind on how those processes were
    > created.
    >
    > However, I think I know how to make it work the way most folks would
    > expect. I'll work on that in the coming weeks.
    >


    That would be great!! But the only thing I need is to be able to send
    a signal to a remote process that I can trap. using SIGINT seems the
    obvious choice on Unix/Linux and I was hoping that it would work the
    same on Windows.

    Another thing that would be great is that you port the park Heesob
    popen call as well in addition to open3. I can;t use the standard
    popen call with win32 utils because the pid arrays are different as
    you know.

    Thanks for your help!

    Laurent

    --
    Laurent JULLIARD
    http://www.moldus.org/~laurent
    Laurent Julliard, Nov 19, 2004
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Carlo Filippini

    Kill win32 process

    Carlo Filippini, Jan 7, 2004, in forum: Perl
    Replies:
    0
    Views:
    1,077
    Carlo Filippini
    Jan 7, 2004
  2. drodrig
    Replies:
    4
    Views:
    13,863
    Roger Upole
    Aug 13, 2006
  3. Tom Plunket

    wx.Process.Kill on Win32

    Tom Plunket, Nov 22, 2006, in forum: Python
    Replies:
    0
    Views:
    485
    Tom Plunket
    Nov 22, 2006
  4. gga
    Replies:
    5
    Views:
    449
    Stephen Kellett
    Sep 23, 2005
  5. Bob Batzinger

    Problems with win32 Process.kill

    Bob Batzinger, Jul 15, 2008, in forum: Ruby
    Replies:
    2
    Views:
    158
    Bob Batzinger
    Jul 16, 2008
Loading...

Share This Page