Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: killed by signal



On Mon, 6 Apr 2009, Peter Stephenson wrote:

$jobstates (from zsh/parameter) tells you. If that's not the answer you'll have to give more details about what you're actually trying to do (which is often the way to get the most useful results).
===============

i can use the return status to figure out if a command was "terminated" by a signal, and which signal was the killer... 128+9 = 137 == KILL. i know the command immediately preceding the precmd was KILLed.

but if a command is suspended (TSTP; 20 on linux, 18 on freebsd) precmd will see a return status <128, which could be a "legal" value for a command to return indicating a particular failure. i'd like precmd to distinguish between a command that returns 18 or 20 (freebsd or linux, respectively), and a command that is suspended with ^Z.

specific example... on freebsd i can get a return status of 18 either by suspending a job with ^Z, or running:
	zip -MM foo.zip no-such-file
so the question is: how can the shell (can the shell?) tell that one of those was suspended with a signal (^Z, TSTP), and zip which is indicating a specific failure (zip: "File not found").

for a few seconds i thought the ERRNO might be useful, but it seems to not be.

thanks...


--
        ...atom

 ________________________
 http://atom.smasher.org/
 762A 3B98 A3C3 96C9 C6B7 582A B88D 52E4 D9F5 7808
 -------------------------------------------------

	"Since trade ignores national boundaries and the manufacturer
	 insists on having the world as a market, the flag of his
	 nation must follow him, and the doors of the nations which
	 are closed against him must be battered down. Concessions
	 obtained by financiers must be safeguarded by ministers of
	 state, even if the sovereignty of unwilling nations be
	 outraged in the process. Colonies must be obtained or
	 planted, in order that no useful corner of the world may be
	 overlooked or left unused."
		-- Woodrow Wilson,
		President of the United States, 1919



Messages sorted by: Reverse Date, Date, Thread, Author