The best i can suggest for writting to a terminal before killing, is to use with the unix write program , or even print directly into the users tty (though that not usually very nice, as if they are typing a command it will interrupt). Once that is done, you could kill the shell as normal. This works diffrent ways on diffrent systems, and on many the echo "foo" > /dev/tty2 trick does not work, so test it on yours.
i had a memory leak once, and it ruined my favorite shirt. | [reply] [d/l] [select] |
Hotshot
I tried what you said, but as you mentioned, the solution you suggested works differntly on different systems, and I wasn't lucky here, so I tried sending SIGPIPE to the process and catch it there, in my sigPipe handler I printed a message to the user and comitted suicide with:
kill('KILL', $$);
and it worked perfectly
but thanks anyway
| [reply] [d/l] |
If I understand your description, the process you're killing is a program that your wrote? In this case, it seems to me that the best way to handle this is to have this program catch the signal that you're sending, print an appropriate message, and exit on its own. This will be much simpler and more reliable than some foreign process trying to write to the user's tty. | [reply] |