zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-workers@zsh.org
Subject: Re: Can't redirect segmentation fault error to file
Date: Fri, 23 Oct 2015 12:06:32 -0700	[thread overview]
Message-ID: <151023120632.ZM7970@torch.brasslantern.com> (raw)
In-Reply-To: <loom.20151023T090442-341@post.gmane.org>

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.


  reply	other threads:[~2015-10-23 19:06 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-23  7:06 Ismail Donmez
2015-10-23 19:06 ` Bart Schaefer [this message]
2015-10-26  7:21   ` Ismail Donmez

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=151023120632.ZM7970@torch.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).