[Debconf-devel] Bug#688806: Crufty stdout fd3 comment in debconf/confmodule

John Morrissey jwm at horde.net
Tue Sep 25 19:53:22 UTC 2012


Package: debconf
Version: 1.5.46
Severity: minor

debconf/confmodule has a crufty comment about stdout on fd3:

    # To actually send something to standard output, send it to fd 3.

fd3 is used to send commands to the frontend, and stdout isn't carried over
from the original shell script invocation, so you can't use fd3 (or stdout
at all) to emit output to stdout.


Originally from debconf-devel@:
http://lists.alioth.debian.org/pipermail/debconf-devel/2012-August/003417.html

------
Date: Tue, 28 Aug 2012 12:23:33 -0700
From: John Morrissey <jwm at horde.net>
To: Debconf Developers <debconf-devel at lists.alioth.debian.org>
Subject: Crufty stdout comment in confmodule?

I was looking at /usr/share/debconf/confmodule recently, and the comment
about stdout and fd 3 seems crufty.

The script winds up with its write pipe to the frontend on fd 3:

debconf.sh 17810  jwm    0r  FIFO    0,8      0t0 9443796 pipe
debconf.sh 17810  jwm    1w   CHR 136,13      0t0      16 /dev/pts/13
debconf.sh 17810  jwm    2u   CHR 136,13      0t0      16 /dev/pts/13
debconf.sh 17810  jwm    3w  FIFO    0,8      0t0 9443797 pipe

If I redirect stderr to a file (by invoking the shell fragment below as
'./debconf.sh 2>foo', for example), I see stdout is completely gone:

debconf.sh 18022  jwm    0r  FIFO    0,8      0t0 9445266 pipe
debconf.sh 18022  jwm    1w   REG  254,6      112 1951755 /home/jwm/newbug/foo
debconf.sh 18022  jwm    2w   REG  254,6      112 1951755 /home/jwm/newbug/foo
debconf.sh 18022  jwm    3w  FIFO    0,8      0t0 9445267 pipe

The frontend starts the shell script with its two pipes on the script's fd0
and fd1, so stdout is never available to the script.

john


/usr/share/debconf/confmodule
--
if [ -z "$DEBCONF_REDIR" ]; then
    # Redirect standard output to standard error. This prevents common
    # mistakes by making all the output of the postinst or whatever
    # script is using this library not be parsed as confmodule commands.
    #
    # To actually send something to standard output, send it to fd 3.
    exec 3>&1
    if [ "$DEBCONF_USE_CDEBCONF" ]; then
        exec 1>&5
    else
        exec 1>&2
    fi
[...]
fi
--

debconf.sh:
--
#!/bin/sh

lsof +c 12 -p $$
. /usr/share/debconf/confmodule
lsof +c 12 -p $$
--
------



More information about the Debconf-devel mailing list