[Asterisk-Dev] Re: is this a bug?

Tilghman Lesher tilghman at mail.jeffandtilghman.com
Wed Jan 26 09:59:50 MST 2005


On Wednesday 26 January 2005 08:16, Andrew Kohlsmith wrote:
> On January 26, 2005 02:03 am, Tilghman Lesher wrote:
> > 1.  If asterisk is a daemon, and running with -c corresponds to
> > running the daemon in the foreground, and you normally expect
> > daemons which are set to run in the foreground to be stopped with
> > Ctrl-C, how does Asterisk break the principle of least
> > astonishment?  I personally run Asterisk with a startup script and
> > connect to it with '-Rc', for which Ctrl-C does NOT interrupt the
> > main process.
>
> I'm sorry, Tlighman, but how many daemons do you know of that offer a
> CLI in "foreground" mode?  You're clearly reaching here.  CLI mode is
> not the same as a "foreground" mode in a regular daemon.

And how many CLIs do you know that start up threads, process jobs, and
exit, without any direction from the keyboard at the CLI?  There's no
reaching here:  Asterisk is obviously not a common daemon OR cli
program, so comparisons to programs which are exclusively daemons or cli
programs obviously don't hold much water.  Arguably, Asterisk is
primarily a daemon program whose CLI has to be activated via a command
line switch and whose CLI provides mainly state and maintenance
procedures, not interactive response (i.e. wait for a command and do
nothing else until that command is received, process the command, then
do nothing else until the user at the console enters another command).
The multithreaded model changes the paradigm quite a bit from the old
paradigms of forking daemons or single-threaded CLI programs.

> I agree with you in the sense that people like me should be running
> asterisk normally and then using asterisk -rc, and that is something
> I plan on changing about how I run asterisk, but the fact that CLI
> dies (even gracefully) with ^C is a minor issue, IMO.

If you look at asterisk.c, you will see that that behavior is completely
intentional, by the fact that there is a signal handler for SIGINT which
calls __quit_handler().  Are you arguing that code that intentionally
catches the signal and starts the quit handler is a bug?

> The question is: if someone were to write a patch that trapped ^C and
> printed "Use STOP NOW or STOP WHEN CONVENIENT to exit Asterisk" would
> it be accepted?

That's a question for Mark.  Obviously, the current behavior is
completely intentional, so changing it would change traditional (and
expected) behavior.

-- 
Tilghman



More information about the asterisk-dev mailing list