Ответ: Chat applet started
Denys Vlasenko
vda.linux at googlemail.com
Tue Feb 12 11:36:14 UTC 2008
[CC:ed to busybox again]
[please do not remove CC when you reply]
On Tuesday 12 February 2008 12:20, Vladimir Dronnikov wrote:
> Although I will conform BB style just say me "Why?!"
Because otherwise CONFIG_WERROR=y build will not work.
I am not a big fan of this, but there are people
who feels strongly about "C is not C++!". Let's respect them.
> + // setup signals
> > + sig_catch(SIGHUP, signal_handler);
> > + sig_catch(SIGINT, signal_handler);
> > + sig_catch(SIGTERM, signal_handler);
> > + sig_catch(SIGPIPE, signal_handler);
> >
> > This is an unfair question, but:
> > And why not SIGQUIT? SIGABRT? SIGALRM? SIGXCPU?
> > Why do you need to catch signals? To ensure that you reset back
> > the tcsetattr?
>
> Yes! Because in BB it's deprecated to use atexit().
> Even if an applet is not NOFORK one.
> We _have to_ restore tty state.
atext would not help here, either.
atexit will not be run if you have some fatal signal
set to SIG_DFL. If fatal signal is set to SIG_DFL,
it works exactly like SIGKILL - *blamm!!* and process
doesn't exist anymore; kernel cleans up after it
(reuses memory, closes file descriptors and so on).
No atexit runs.
I guess we need
bb_signals(int signals_bitmask, handler);
which can be used like this:
bb_signals(0
+ (1 << SIGHUP)
+ (1 << SIGINT)
+ (1 << SIGTERM)
+ (1 << SIGPIPE)
+ (1 << SIGQUIT)
+ (1 << SIGABRT)
+ (1 << SIGALRM)
+ (1 << SIGXCPU)
, signal_handler);
to install handler for many signals.
--
vda
More information about the busybox
mailing list