zsh-workers
 help / color / mirror / code / Atom feed
* Can't redirect segmentation fault error to file
@ 2015-10-23  7:06 Ismail Donmez
  2015-10-23 19:06 ` Bart Schaefer
  0 siblings, 1 reply; 3+ messages in thread
From: Ismail Donmez @ 2015-10-23  7:06 UTC (permalink / raw)
  To: zsh-workers

Hi,

Suppose I have a crashing executable:

λ ./a.out            
[1]    6511 segmentation fault (core dumped)  ./a.out


For some reason I want to redirect the segmentation fault error to a file.

λ { ./a.out; } 2> err
λ 

I do that and err is an empty file. Same thing seems to work fine in bash. I 
tried with zsh 5.1.1 without success.

 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Can't redirect segmentation fault error to file
  2015-10-23  7:06 Can't redirect segmentation fault error to file Ismail Donmez
@ 2015-10-23 19:06 ` Bart Schaefer
  2015-10-26  7:21   ` Ismail Donmez
  0 siblings, 1 reply; 3+ messages in thread
From: Bart Schaefer @ 2015-10-23 19:06 UTC (permalink / raw)
  To: zsh-workers

On Oct 23,  7:06am, Ismail Donmez wrote:
}
} Suppose I have a crashing executable:
} 
} For some reason I want to redirect the segmentation fault error to a file.

The segmentation fault error isn't printed by the failing command, it's
printed by the shell when it is notified of the failed exit status of
the command.

Zsh sends job control messages to the "shell output" (typically the
terminal) rather than to standard error, so redirecting standard error
won't trap anything.

That said, I'm not entirely sure why it doesn't print anything at all:

torch% bash -c 'kill -SEGV $$'
zsh: segmentation fault (core dumped)  bash -c 'kill -SEGV $$'
torch% { bash -c 'kill -SEGV $$' }
torch% 

Braces suppress job exit status messages as far back as zsh 4.2.0 (maybe
farther).

One other thing -- I'm not sure why you're getting

[1]    6511 segmentation fault (core dumped)  ./a.out

when in your example the job does not appear to have been backgrounded.
The job number "[1]" should only appear like that for background jobs:

torch% bash -c 'kill -SEGV $$' &
[1] 7957
torch% 
[1]  + 7957 segmentation fault (core dumped)  bash -c 'kill -SEGV $$'

and in THAT case I get:

torch% { bash -c 'kill -SEGV $$' & } 2>err
[2] 7963
torch% 
[2]  + segmentation fault (core dumped)  bash -c 'kill -SEGV $$'
torch% cat err
torch% 

In 4.2 the job start message is printed to stderr, but the job termination
message is not:

zsh-4.2.0% { bash -c 'kill -SEGV $$' & } 2>err
zsh-4.2.0% 
[2]  + 7959 segmentation fault (core dumped)  bash -c 'kill -SEGV $$'
zsh-4.2.0% cat err
[2] 7959
zsh-4.2.0% 

So where the messages go is at least now consistent in 5.1.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Can't redirect segmentation fault error to file
  2015-10-23 19:06 ` Bart Schaefer
@ 2015-10-26  7:21   ` Ismail Donmez
  0 siblings, 0 replies; 3+ messages in thread
From: Ismail Donmez @ 2015-10-26  7:21 UTC (permalink / raw)
  To: zsh-workers

Bart Schaefer <schaefer <at> brasslantern.com> writes:

> 
> On Oct 23,  7:06am, Ismail Donmez wrote:
> }
> } Suppose I have a crashing executable:
> } 
> } For some reason I want to redirect the segmentation fault error to a 
file.
> 
> The segmentation fault error isn't printed by the failing command, it's
> printed by the shell when it is notified of the failed exit status of
> the command.
> 
> Zsh sends job control messages to the "shell output" (typically the
> terminal) rather than to standard error, so redirecting standard error
> won't trap anything.
> 
> That said, I'm not entirely sure why it doesn't print anything at all:

This seems to be contradicting to what bash does:

> { ./a.out; } 2> foo
> cat foo
Segmentation fault (core dumped)
> bash --version
GNU bash, version 4.3.42(1)-release (x86_64-suse-linux-gnu

And indeed zsh always seems to print [1] as if the program goes to 
background.

Well for now I can live with it.



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-10-26  7:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-23  7:06 Can't redirect segmentation fault error to file Ismail Donmez
2015-10-23 19:06 ` Bart Schaefer
2015-10-26  7:21   ` Ismail Donmez

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).