SIGSTOP and SIGKILL


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting SIGSTOP and SIGKILL
# 1  
Old 02-18-2011
SIGSTOP and SIGKILL

Which is sent to a terminal when it closes? SIGKILL? Reason I ask is I have a script I want to run in the background, but want it to run even if the terminal window is closed. Or, I'd like it to background itself if the terminal is closed but not if its running in an open window. I will learn how to trap if its possible to do this I just need to account for accidental closures and such to make it clean up nice. Thank you for any answers.
# 2  
Old 02-18-2011
SIGHUP is sent to processes when their controlling terminal is closed. You may be interested in reading the nohup(1) man page if you'd like a process to ignore that signal.

Regards,
Alister

Last edited by alister; 02-18-2011 at 12:25 AM..
This User Gave Thanks to alister For This Post:
# 3  
Old 02-18-2011
Perfect. There's no thank you button on your post for some reason but thank you. That was the trick
# 4  
Old 02-20-2011
Ok found the caveat: If any of my conditions have an exit 0, the terminal prompt doesn't come back. I can still type commands successfully but i have to manually issue a ^C interrupt to the terminal if I want the prompt back. I've tried adding kill -s $SIGSSTOP $! to my script to no avail. Any ideas?
# 5  
Old 02-20-2011
Assuming that the script does not output anything to the terminal.
This construct will background a script and leave it running whether or not the terminal logs out. The script itself must contain some means of stopping it whether it be testing for a flag file or coding a suitable "trap" statement in the script to react to a "kill".
Code:
nohup myscriptname &

# 6  
Old 02-20-2011
The script indeed has terminal output and exit codes for success and non successful termination. When complete it doesnt return the prompt but if i type ls it will ls as if i were at a prompt. I want the script to ignore hangups programmatically not when i invoke it. Trapping hup seems right
Login or Register to Ask a Question

Previous Thread | Next Thread

4 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to detect SIGTERM,SIGKILL signal in UNIX

Dear All We have JBOSS server running on Linux we need to track Graceful Shutdown(SIGTERM) and Forceful Shutdown(SIGKILL) timestamp and write it into one file, I am new to UNIX Signal processing if is it possible how to detect it? We generally do $kill PID For Graceful... (5 Replies)
Discussion started by: mnmonu
5 Replies

2. Solaris

SIGQUIT and SIGKILL message

Dear All, I have machine with SunOS 5.10 Generic_138888-01 sun4v sparc SUNW,SPARC-Enterprise-T5120. Yesterday there is something at dmesg command : May 25 18:09:02 cacao_launcher: Timeout occured on heartbeat channel, cleanup engaged May 25 18:09:07 cacao_launcher: watchdog : warning,... (0 Replies)
Discussion started by: mbah_jiman
0 Replies

3. Programming

How to implement SIGKILL and SIGTERM and print a message?

Hello, I am running a webserver that uses sockets, forks, and children. The parent process listens for connections and the child processes the information. I am trying to figure out why the code I have below SIGTERM, and SIGKILL never fire. I was messing around with the printfs and doesnt... (11 Replies)
Discussion started by: norelco55
11 Replies

4. Shell Programming and Scripting

Why SIGKILL will occur?

Hi Gurus, I am executing my Datastage jobs on UNIX operating System. While running the jobs i am getting the following error: main_program: Unexpected termination by Unix signal 9(SIGKILL) Can any one please let me know what are the possible situations where this SIGKILL will arrise? ... (9 Replies)
Discussion started by: choppas
9 Replies
Login or Register to Ask a Question