Unix/Linux Go Back    

UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD.

Source Output

UNIX for Advanced & Expert Users

Thread Tools Search this Thread Display Modes
Old Unix and Linux 10-11-2012   -   Original Discussion by ticiotix
bakunin bakunin is offline Forum Staff  
Bughunter Extraordinaire
Join Date: May 2005
Last Activity: 15 November 2017, 4:57 AM EST
Location: In the leftmost byte of /dev/kmem
Posts: 5,633
Thanks: 107
Thanked 1,603 Times in 1,180 Posts
Originally Posted by Don Cragun View Post
Obviously, the commands specified by the action in a trap action EXIT command won't be executed if the shell is terminated by a SIGKILL signal since the shell can't catch a SIGKILL to invoke the actions specified by appropriate traps.
True. This notable exception i have explicitly stated (in post #4, last line). It is because of the nature of this signal, which is not directed at the process but rather at the kernel. A process terminated by SIGKILL doesn't terminate itself, but rather is terminated by the kernel.

If the standard is interpreted as you expect, then no system conforms to the standard because the standard doesn't allow an exception for being terminated by SIGKILL.
Actually what i tried to get across was: save for SIGKILL, any other way of terminating a script (simple end, send a SIGTERM via "kill -15", press "CTRL-C", ...) will result in trap 0 (EXIT) being executed - not just using the "exit" built-in.

This is in fact as it should be because a script terminated by "kill -9" probably best leaves its temporary files for further inspection (one wouldn't terminate a script this way without some serious reason) and all other methods of ending a script are covered.

Thanks for sharing your thoughts.

Sponsored Links

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Redirect output to a different text file depending source of data spartan22 Shell Programming and Scripting 4 07-17-2012 11:10 AM
Read rows from source file and concatenate output carlos_anubis UNIX for Dummies Questions & Answers 0 07-22-2010 10:44 AM
write page source to standard output wxornot Shell Programming and Scripting 1 07-18-2008 05:46 PM
how to make a line BLINKING in output and also how to increase font size in output mail2sant Shell Programming and Scripting 3 04-14-2008 08:30 AM

All times are GMT -4. The time now is 07:08 PM.