Kill Signal Number? - Help !

This is a discussion on Kill Signal Number? - Help ! within the C Programming forums, part of the General Programming Boards category; Hi I'm using the following C function: #include <signal.h> int kill(pid_t pid, int sig); This C function requires a signal ...

  1. #1
    Registered User
    Join Date
    Sep 2003
    Posts
    30

    Kill Signal Number? - Help !

    Hi I'm using the following C function:

    #include <signal.h>

    int kill(pid_t pid, int sig);

    This C function requires a signal number. I have read that these can vary from system to system. Is this true? If so how can you get a particular systems table of kill signal numbers?

    Where can I get a generic kill signal number table?

    Also can anyone tell me the "STOP" and "CONT" signal numbers?

    Thanks

  2. #2
    Registered User
    Join Date
    Sep 2006
    Posts
    835
    On my box, "man 7 signal" shows the signal numbers. Some of them including the two you want are listed as being architecture-dependent. On my box, <bits/signum.h> contains macros for the signal numbers. You could just use SIGSTOP and SIGCONT.

  3. #3
    Registered User
    Join Date
    Sep 2003
    Posts
    30
    So I could just enter something like:

    kill(pid, SIGSTOP);

    ??

  4. #4
    Registered User
    Join Date
    Sep 2006
    Posts
    835
    Yes. I noticed that on my Linux box, <signal.h> includes <bits/signum.h>, so you would only have to include the former. You should check whether this is true on your system and how portable this is if that's important to you.

    Edit: Also see "man 2 kill". That indicates the proper include files.
    Last edited by robatino; 06-19-2007 at 08:21 PM.

  5. #5
    Day Dreamer
    Join Date
    Apr 2007
    Posts
    45
    Yes you can very well use the macros defined in <bits/signum.h> with the kill system call instead of bothering to remember the exact numbers representing them.

  6. #6
    Registered User
    Join Date
    Sep 2003
    Posts
    30
    Many thanks to all who replied, I've got it working how I want now, just used SIGSTOP and SIGCONT.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. scanf oddities
    By robwhit in forum C Programming
    Replies: 5
    Last Post: 09-22-2007, 01:03 AM
  2. NAQ: Everything you never wanted to know about CPP
    By evildave in forum C Programming
    Replies: 21
    Last Post: 12-12-2005, 09:56 AM
  3. using a signal handler to kill processes
    By dinjas in forum C Programming
    Replies: 2
    Last Post: 03-16-2005, 11:58 AM
  4. Prime number program problem
    By Guti14 in forum C Programming
    Replies: 11
    Last Post: 08-06-2004, 04:25 AM
  5. Random Number problem in number guessing game...
    By -leech- in forum Windows Programming
    Replies: 8
    Last Post: 01-15-2002, 04:00 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21