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

Re: killed by signal

On Tue, 7 Apr 2009, Atom Smasher wrote:

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").

here's a hack.... after a command is suspended, $? is updated but $pipestatus isn't. so if
	[[ ${?} != ${${=pipestatus}[-1]} ]]
 then the preceding command must have been suspended.

but it doesn't work all the time: if a command returns with an exit status equal to a suspend signal (which is probably rare), and the next command is suspended with that signal, that would result in a false negative; failing to detect that a command was suspended... but most of the time it should work, and i don't think it's possible to get a false positive.

if anyone has a better way to do it...


 762A 3B98 A3C3 96C9 C6B7 582A B88D 52E4 D9F5 7808

	"I spent 33 years in the Marines. Most of my time being a
	 high-class muscle man for Big business, for Wall Street and
	 the bankers. In short, I was a racketeer for capitalism. I
	 helped purify Nicaragua for the international banking house
	 of Brown Brothers in 1909-1912. I helped make Mexico and
	 especially Tampico safe for American oil interests in 1914.
	 I brought light to the Dominican Republic for American sugar
	 interests in 1916. I helped make Haiti and Cuba a decent
	 place for the National City Bank boys to collect revenue in.
	 I helped in the rape of half a dozen Central American
	 republics for the benefit of Wall Street"
		-- Smedley D. Butler, (1881-1940)
		Major Gen U.S. Marines
		at the time of his death the most
		decorated U.S. Marine in history

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