X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=docs%2Fsigint.htm;h=d656aeb8ce3611a81ad366cf1314c41d3f6f9188;hb=31c765081dc41f158786545fbea9294be4685bd2;hp=6fe76bbef84dcdd07532fcd5fc2fd1626c2d80c0;hpb=4126b1f5c6983b7c2dd4f92d635ab762d861c2d6;p=oweals%2Fbusybox.git diff --git a/docs/sigint.htm b/docs/sigint.htm index 6fe76bbef..d656aeb8c 100644 --- a/docs/sigint.htm +++ b/docs/sigint.htm @@ -40,12 +40,12 @@ scripts using Control-C. Or have interactive applications that don't behave right when sending SIGINT. Examples are emacs'es that die on Control-g or shellscript statements that sometimes are executed and sometimes not, apparently not determined by the user's -intention. +intention. Required knowledge: You have to know what it means to catch SIGINT or SIGQUIT and how -processes are waiting for other processes (childs) they spawned. +processes are waiting for other processes (children) they spawned. @@ -101,7 +101,7 @@ just exit.

Now imagine the user hits C-c while a shellscript is executing its first program. The following programs receive SIGINT: program1 and -also the shell executing the script. program1 exits. +also the shell executing the script. program1 exits.

But what should the shell do? If we say that it is only the innermost's programs business to react on SIGINT, the shell will do @@ -351,7 +351,7 @@ that do not properly communicate the required information up to the calling program.

Unless a program messes with signal handling, the system does this -automatically. +automatically.

There are programs that want to exit on SIGINT, but they don't let the system do the automatic exit, because they want to do some @@ -366,7 +366,7 @@ signal, it has to take care of communicating the signal status itself.

Some programs don't do this. On SIGINT, they do cleanup and exit -immediatly, but the calling shell isn't told about the non-normal exit +immediately, but the calling shell isn't told about the non-normal exit and it will call the next program in the script.

As a result, the user hits SIGINT and while one program exits, the @@ -425,7 +425,7 @@ Notes: special numeric value. People often assume this since the manuals for shells often list some return value for exactly this. But this is just a convention for your shell script. It does not work from one UNIX API -program to another. +program to another.

All that happens is that the shell sets the "$?" variable to a special numeric value for the convenience of your script, because your @@ -446,7 +446,7 @@ handlers, so it is portable. trap command. Here, the same as for C programs apply. If the intention of SIGINT is to end your program, you have to exit in a way that the calling programs "sees" that you have been killed. If -you don't catch SIGINT, this happend automatically, but of you catch +you don't catch SIGINT, this happened automatically, but of you catch SIGINT, i.e. to do cleanup work, you have to end the program by killing yourself, not by calling exit. @@ -466,7 +466,7 @@ files (which isn't really portable in C, though). bourne shell. Every language implementation that lets you catch SIGINT should also give you the option to reset the signal and kill yourself. -

It is always desireable to exit the right way, even if you don't +

It is always desirable to exit the right way, even if you don't expect your usual callers to depend on it, some unusual one will come along. This proper exit status will be needed for WCE and will not hurt when the calling shell uses IUE or WUE. @@ -565,13 +565,13 @@ comments the scripts echo. What happens when a shellscript called emacs, the user did not use C-c and the script has additional commands in it? What happens if a non-interactive child catches SIGINT? -To behave properly, childs must do what? +To behave properly, children must do what? IUE The shell executing a script exits immediately if it receives -SIGINT. +SIGINT. 4.4BSD ash (ash), NetBSD, FreeBSD prior to 3.0/22.8 The editor session is lost and subsequent commands are not executed. @@ -605,7 +605,7 @@ will further commands from the script be executed. signal (either it had the default handler for SIGINT or it killed itself). bash (Linux /bin/sh), most commercial /bin/sh, FreeBSD /bin/sh -from 3.0/2.2.8. +from 3.0/2.2.8. The editor continues as normal and subsequent commands are executed. The editor continues as normal and subsequent commands are @@ -615,7 +615,7 @@ child exits, but only if the child exited with signal status. If the child did a normal exit (even if it received SIGINT, but catches it), the script will continue. The child must be implemented right, or the user will not be able -to break shell scripts reliably. +to break shell scripts reliably.