In article <42************ ***********@new s.cybernetik.ne t>,
Kristofer <kr*******@cybe rnetik.net> wrote:
Seven Kast USA wrote: if we running a c program , that if u press ctrl +d or +z or +c ,
then program will closed.. what behind processing .........
That's not for this newsgroup, but CTRL-C is sending a break to the
program, which usually makes the operating system stop it (you can set
up signals to catch this, but again, thats not for this group).
[OT]
That's right, but for Unix in another way it isn't.
In Unix, each input stream may be interpreted by a "line discipline"
layer, which interprets the input and may perform special processing.
In Ye Olde Dayes, only interactive serial lines had line disciplines;
after several years, "pseudo-terminals" were added that could have line
disciplines too. In Unix systems that handle inputs in terms of
"Streams" [note the capital S], -any- input stream can have a line
discipline module added to it (possibly leading to unintended
results...)
A line discipline layer examines each character as it comes in, and
does whatever processing it's configuration tables tells it to. That
processing might include echoing the character as well as buffering it,
or might include deleting a character from the input buffer, or
suspending the current job, or a number of other things.
When a line discipline layer reads the character that is currently
configured as the interrupt character (control-C and DEL are the two
most common settings for this, but it is configurable), then -if it is
in the appropriate processing context[*]-, the layer would use kill()
or raise() other appropriate call in order to send a signal to the
program that is being controlled. The way that program reacts will
depend upon what signal handler is in effect for the appropriate
signal.
The fundamental difference between this description and the previous is
in the phrase "sending a break to the program". A "break" would be an
inband marker, but udp has no mechanism for indicating breaks and the
tcp mechanism that could convey breaks is optional and not implemented
particularily commonly, and the appropriate detection mechanism for
that tcp facility are built into programs even less commonly. A signal,
though, is an out-of-band operation undertaken by the operating system
(and which can often only be carried to local processes.)
[*] "In the right processing context" -- there can be several contexts
in which the interrupt character does not mean "interrupt" . For
example, it might have been proceeded by a quote-next-character
indicator, or the input layer might be in an editting mode in which the
interrupt character might mean something else completely such as
"delete the previous character" or "copy the saved input buffer".
--
Entropy is the logarithm of probability -- Boltzmann