Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

sending kill signals from perl CGIs

by tachekent (Acolyte)
on Jan 02, 2003 at 03:07 UTC ( #223670=perlquestion: print w/replies, xml ) Need Help??

tachekent has asked for the wisdom of the Perl Monks concerning the following question:

I have a perl process running. When it starts up it writes it's PID into a file. It also has a signal trap.

When I run a file (kill.pl) with this code in it from the command line, it traps the signal:

#!/usr/bin/perl -w # attempt to kill a pid use strict; my $pid; open (PID, "<signwriter.pid"); while(<PID>){ $pid = $_; } kill 'ALRM', $pid;
However, if I run the same code as part of a CGI process (called from a web-form), or if I try and run kill.pl from
system "perl ./kill.pl";
nothing seems to happen.

I don't understand :(

Replies are listed 'Best First'.
Re: sending kill signals from perl CGIs
by chromatic (Archbishop) on Jan 02, 2003 at 03:17 UTC

    You may not have permission to send that signal from the user account as whom the CGI program runs, and you're probably not in the right directory. Add some error checking and see what it tells you.

Re: sending kill signals from perl CGIs
by mce (Curate) on Jan 02, 2003 at 12:39 UTC
    Hi,

    In unix, only root can kill all processes and the other users can only kill their own.

    I suggest you should go for a tool called sudo and configure it so that the www (or apache or whatever) can only run this script. Than you need to call

    system("sudo kill.pl");
    from inside your cgi code.
    I hope this helps.
    ---------------------------
    Dr. Mark Ceulemans
    Senior Consultant
    IT Masters, Belgium
Re: sending kill signals from perl CGIs
by fglock (Vicar) on Jan 02, 2003 at 13:15 UTC

    I suggest you try starting the process from a CGI. This way you would have the rights to kill it from another CGI!

Re: sending kill signals from perl CGIs
by tachekent (Acolyte) on Jan 02, 2003 at 03:26 UTC
    I thought it might be the perl user.
    All the files are in the same directory - I sorted that out.
    Is there a way to override this or set up the CGI user so that it can send that signal?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://223670]
Approved by rob_au
Front-paged by wil
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (3)
As of 2023-12-01 20:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What's your preferred 'use VERSION' for new CPAN modules in 2023?











    Results (5 votes). Check out past polls.

    Notices?