Thread: my kill() wont work

  1. #1
    Registered User
    Join Date
    Jun 2008
    Posts
    8

    my kill() wont work

    hi im working in UNIX and what im doing here is storing the pid's into a queue and then using this process for killing X amount of pids, however when ever it reaches this point it always outputs " Killed" and kills the whole thing not the pid that is put into temp

    i have changed kill(temp, SIGKILL); from kill( Queue[0], SIGKILL); to try make it work but no luck

    Code:
    			temp = Queue[0];
    			kill(temp, SIGKILL);
    			for (i = 0; i < top; i++)
    			{		
    				Queue[i] = Queue[i+1];
    			}
    im sure im missing something obvious thanks any input would be greatly appreciated

  2. #2
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Where are you getting the pids from? Have you tried outputing the value first to make sure it is what you think it is?
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  3. #3
    Registered User
    Join Date
    Jul 2010
    Posts
    26
    Check the value of temp just before calling kill(). According to man 2 kill, kill() kills multiple processes if the pid supplied is not positive.

    Quote Originally Posted by man 2 kill
    If pid equals 0, then sig is sent to every process in the process group of the
    calling process.

    If pid equals -1, then sig is sent to every process for which the calling process
    has permission to send signals, except for process 1 (init), but see below.

    If pid is less than -1, then sig is sent to every process in the process group
    whose ID is -pid.

  4. #4
    Registered User
    Join Date
    Jun 2008
    Posts
    8
    hi thanks for the replys it was a case of temp holding 0 its all fixed now

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How do I use signals sent from the kill() Linux call?
    By jsrig88 in forum C Programming
    Replies: 3
    Last Post: 10-10-2009, 10:20 PM
  2. Why don't the tutorials on this site work on my computer?
    By jsrig88 in forum C++ Programming
    Replies: 3
    Last Post: 05-15-2006, 10:39 PM
  3. Problems in getting OpenGL to work
    By zonf in forum C Programming
    Replies: 5
    Last Post: 02-13-2006, 04:48 AM
  4. Why won't my OpenGL work?
    By Raigne in forum C++ Programming
    Replies: 7
    Last Post: 11-26-2005, 11:53 AM
  5. Developers Wanted
    By Quasicom in forum Projects and Job Recruitment
    Replies: 2
    Last Post: 08-24-2005, 12:46 AM