OT - line disciplines [was: Re: What IS THIS]



In article <42d536c7$0$53340$d5a6236f@xxxxxxxxxxxxxxxxxxx>,
Kristofer <kristofer@xxxxxxxxxxxxxx> 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
.



Relevant Pages

  • Re: getline and CR, LF, CR/LF, VS/Linux
    ... >> crlf sequences or into the single lf character. ... the operating system will stop reading even though most of the file is ... This is an ancient problem and you can't blame Windows. ...
    (microsoft.public.vc.stl)
  • Re: How to terminate a text file line in Unicode (in Java)
    ... In this case, technically, I might use any character sequence ... though the text file isn't really a text file if its line terminator is not one of the characters designated for such use in character code standards. ... This is somewhat obscure (since the operating system need not use such a convention) and reflects lack of rigorous standardization of the language. ... I guess both candidates are feasible, with no clear preference, but the context and purpose may make one of them preferable. ...
    (comp.std.internat)
  • Beyond Vista!! 3D Desktop Environment/OS Prototype
    ... for a 3D map of icons in a first person point of view building. ... load to initialize the operating system. ... the character, an x,y for the pointer. ... you'll see that you can produce any kind of terrain ...
    (microsoft.public.windows.vista.general)
  • 3D Desktop Environment/OS Prototype
    ... I was thinking about the security of an Operating System, and how that could remain just as organized as a file system. ... Imagine that when your computer boots up, it's waiting for a 3D map of icons in a first person point of view building. ... The added security is in that your first person character has to be located at a specific set range of coordinates to face and reach for/click on the icon. ... what I was thinking was to use a 3D graphing routien adopted for the sake of producing terrain maps that could literally go on for what would seem to be thousands of miles. ...
    (microsoft.public.windows.vista.general)
  • Re: Ages everyone?
    ... If the signals went out 'linearly' there ... Surrounding text with $..$ puts the surrounded text in 'math mode' ... character set and font). ...
    (rec.games.frp.dnd)