send command to parent shell
nobody at nowhere.com
Wed Oct 13 16:23:01 CEST 2010
On Wed, 13 Oct 2010 06:30:15 -0700, Martin Landa wrote:
> is there a way how to send command from python script to the shell
> (known id) from which the python script has been called?
For Unix, this should work, but in general it's the wrong thing to do:
This is a rather unfriendly way to kill the shell (it won't be able to
save its history, etc), and if the program was started from something
other than a shell, you might kill something you don't want to.
Using SIGHUP is more friendly and will probably work, but it could be
caught and/or ignored (for bash, SIGTERM, SIGQUIT and SIGINT /will/ be
ignored). If the shell can catch the signal in order to save its history,
it can catch it and ignore it.
There isn't a nice way to do it. There isn't supposed to be a nice way to
do it. Processes may control their children, but a child isn't supposed to
control its parent.
More information about the Python-list