Re: Why does login_tty(int fd) close fd at the end?



On Wed, Jun 6, 2012 at 1:01 AM, Regid Ichira <regid23@xxxxxxxxx> wrote:
 Isn't closing fd at the end makes all the work meaningless?

   $ man login_tty| grep -A6 'The  login_tty() '
          The  login_tty()  function  prepares for a login on the tty fd
          (which may be a real tty device, or the slave of a  pseudoter-
          minal  as  returned  by  openpty()) by creating a new session,
          making fd the controlling terminal for  the  calling  process,
          setting fd to be the standard input, output, and error streams
          of the current process, and closing fd..


Note the "setting fd to be the standard input, output, and error
streams" text. It will probably dup(2) the fd to be stdin, stdout,
and stderr. After that closing the original fd has no effect on the
newly created descriptors.

--
regards,
kushal


--
To UNSUBSCRIBE, email to debian-user-REQUEST@xxxxxxxxxxxxxxxx
with a subject of "unsubscribe". Trouble? Contact listmaster@xxxxxxxxxxxxxxxx
Archive: http://lists.debian.org/CAH8GtdPf8rZYrhk_RJPW5rO+2XkZJOHPk0HEDd8T8nP6crG-tw@xxxxxxxxxxxxxx



Relevant Pages

  • Re: are stdout and stderr different
    ... It's customary for stderr to be unbuffered while stdout is usually line ... 'stdin, 'stdout', 'stderr' need not to be modifiable lvalues. ... "flushing" input streams doesn't ...
    (comp.lang.c)
  • Re: Teaching C
    ... descriptors at all, so that stdin, stdout, and stderr are all ... as stdin, the next as stdout, and the next as stderr. ...
    (comp.lang.c)
  • Re: Teaching C
    ... The first fopensuccessful call ends up functioning ... as stdin, the next as stdout, and the next as stderr. ...
    (comp.lang.c)
  • Re: executing external binaries
    ... >>loaded in the memory ... > If you only need to feed it on STDIN and not collect output, ... > it's STDOUT and STDERR ...
    (perl.beginners)
  • Re: Python as a scripting language. Alternative to bash script?
    ... Can Python access the exit status of a program? ... (easy access to stdout, stderr, error code). ... stdin - Text to feed to process's stdin ...
    (comp.lang.python)