Terminate a python script from linux shell / bash script

G

Gros Bedo

Hello :)

I have a question about Python and Linux shell. I have a python program which is permanently resident in the end-user system. I'm currently producing a RPM package, and it works nicely. The problem is that when I uninstall it, my program keeps running in the background, even if the files are deleted.

I know I can terminate python shell directly, but this is not a good idea because the end-user may be working with another important python application, and would be very angry if mine would close everything that is using python shell.

So, is there a way from the Linux shell or a bash script to terminate just one specific Python script ?
_________________________________________________________________
Votre contact a choisi Hotmail, l'e-mail nouvelle génération. Créez un compte.
http://www.windowslive.fr/hotmail/default.asp
 
M

MRAB

You should use the signal module to look for SIGINT signal and exit if it is
received.
An alternative, though crude, hack is for the script to check for the
existence (or non-existence) of a special file and quit if found (or
not found). It could also create it when it starts or delete it when
it quits, as appropriate.
 
P

Piet van Oostrum

Gros Bedo said:
GB> I have a question about Python and Linux shell. I have a python
GB> program which is permanently resident in the end-user system. I'm
GB> currently producing a RPM package, and it works nicely. The problem is
GB> that when I uninstall it, my program keeps running in the background,
GB> even if the files are deleted.
GB> I know I can terminate python shell directly, but this is not a good
GB> idea because the end-user may be working with another important python
GB> application, and would be very angry if mine would close everything
GB> that is using python shell.

That's not how it works. If you kill one running python script it will not
effect other python scripts. Each script has its own interpreter process
running.
GB> So, is there a way from the Linux shell or a bash script to terminate
GB> just one specific Python script ?

So just kill it.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,816
Latest member
SapanaCarpetStudio

Latest Threads

Top