Avinash,
The last suggestion which surrounded the kill command with grave
accents (`kill -9 PID`) was essentially causing perl to spawn a
process and running UNIX kill command. If this fails to work, then
your problem has nothing to do with perl. Check the following:
1) Make sure that the value that $pid[$_] evaluates to is in fact the
process number of some existing process. You might want to go back to
your original version to verify what the value is. You should get the
word kill (all lower case).
2) The perl kill function takes small positive integer values for the
various signals, whereas with the UNIX shell level kill command, the
signal value is immediately preceded by a dash. Using a negative value
means to send the signal to all the members of a process group which
is likely NOT what you intended to do. Perl documentation cannot tell
you what will happen or exactly what values to use. You MUST consult
your UNIX documentation with the man command (see below).
3) Please be aware that any process in a Unix/Linux system cannot kill
(i.e., send a signal to another process) unless that other process has
permission to do so. If you try typing an explicit kill -9 PID command
at the shell and the process does not die, then you do not have
permission to kill it. I won't attempt to explain how the permission
system works, nor the details of what processes generally are able to
send signals to other processes other than to say that the ROOT (super
user) can do anything, whereas most other processes can only send
signals to other processes created by the same user.
4) If you are not familiar with what signals are or how the
permissions system works with UNIX, then you might want to consult
your online documentation. Type: man kill <return> to get started.
5) Should you want to get better results from using a group like this,
be sure that you have a decent grasp of your problem first and provide
us with the essential information. There is nothing magical about
Perl's kill command, since it most assuredly invokes the local Unix
system kernel using the same system call that the shell's kill command
does. Any properly installed UNIX or UNIX derivative system like
Cygwin or Linux should have manual pages. If the specific manual page
you view doesn't provide you with the clue you need, then go to the
bottom of the manual page and check one or more cross referenced
pages. Also, if you perform any tests, provide us with enough clues of
what happens so that we can be of help to you, otherwise you're just
wasting your time and ours.
Good luck,
Glen
--- In Perl_Official@yahoogroups.com, avinash k <avik1612@...> wrote:
>
> hi,
>
> i am using the unix opearting system.
> I have attached the code
> It is still not able to kill the process
>
> Thanks in advance
> Avinash
>
> rob_wilson_98 <no_reply@yahoogroups.com> wrote:
> --- In Perl_Official@yahoogroups.com, avinash k
<avik1612@> wrote:
> >
> > hi,
> >
> > i am trying this statement but it is not executing i.e. killing
> process
> >
> > $force ="-9";
> >
> > print "Kill $force $pid[$_]\n";
> >
> >
> > Thanks and Regards
> > Avinash
> >
> >
>
> All your script would do is print out a Kill message. It will not
> execute the Kill command. In fact, I am not aware of a "Kill"
> command. If you're on Windows, you must have some sort of unix-like
> toolkit involved and then you'd probably still need the "kill" command
> - note no capitalization. On Unix things are case-sensitive so you
> have to use the "kill" command. It also has to be in your path (it
> normally is by default).
>
> Perhaps you're looking for something like:
>
> $force = "-9";
> `kill $force $pid[$_]`;
>
> If that's not what you want, post more information such as the OS,
> what you're trying to accomplish, and what _exactly_ seems to be the
> problem (error messages, observed behavior, output from "use strict"
> or "-w", etc.
>
>
>
>
>
>
>
>
>
>
>
>
>
> ---------------------------------
> Once upon a time there was 1 GB storage in your inbox. Click here
for happy ending.
>
> [Non-text portions of this message have been removed]
>