[Debconf-devel] Crufty stdout comment in confmodule?

John Morrissey jwm at horde.net
Tue Aug 28 19:23:33 UTC 2012


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 $$
--


john
-- 
John Morrissey          _o            /\         ----  __o
jwm at horde.net        _-< \_          /  \       ----  <  \,
www.horde.net/    __(_)/_(_)________/    \_______(_) /_(_)__



More information about the Debconf-devel mailing list