help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-bash] trap when expected return value may be non-zero?


From: Bob Proulx
Subject: Re: [Help-bash] trap when expected return value may be non-zero?
Date: Thu, 2 May 2013 14:14:27 -0600
User-agent: Mutt/1.5.21 (2010-09-15)

adrelanos wrote:
> SIGQUIT (Issued if the user sends a quit signal (Ctrl + D).) Well, I
> think Ctrl + C is more common than Ctrl + D. If one really wants this
> and stops my scripts this way, so be it. I think having one way to stop
> it while cleaning and and one just exiting is good.

SIGQUIT is usually issued by the tty driver upon Control-\ not C-d.
The SIGQUIT is useful with C programs such as during an infinite
loop.  Use C-\ to trigger a SIGQUIT to stop the loop and dump a core.
Use a debugger to examine the core and see where the program was
looping.  (Yes, there are many useful alternatives such as attaching
to the running process with a debugger.)

Control-d usually causes read(2) to return with whatever input it has
accumulated to that point.  Which is to say zero bytes if none has
accumulated A zero byte read(2) is usually interpreted as
end-of-file which normally causes anything reading from stdin to
terminate normally.

See the output of 'stty -a' to see which is configured for your
particular terminal driver.

How common any of these actions are depends upon the knowledge,
experience and culture of the users in the environment.  In mine C-d
is extremely common.  But C-\ not so much so.  Although it is useful
for programs that inappropriately trap SIGINT because SIGQUIT is a
different signal and not usually trapped in compiled C programs. :-)

Bob



reply via email to

[Prev in Thread] Current Thread [Next in Thread]