urxvtd and file descriptors

Aron Griffis agriffis at n01se.net
Thu Jan 29 02:36:01 CET 2009


Marc Lehmann wrote:  [Wed Jan 28 2009, 07:00:25PM EST]
> On Wed, Jan 28, 2009 at 01:03:50PM -0500, Aron Griffis <agriffis at n01se.net> wrote:
> > I recently switched to urxvtd.  Today I noticed that fds 5 and
> > 8 are open in all my terminals.  Is that expected?
> 
> well, terminals can't have file descriptors, only processes
> have them. What do you mean with "terminals"? 

My shells.  For example:

$ ls -l /dev/fd/
total 0
lrwx------ 1 agriffis agriffis 64 2009-01-28 20:29 0 -> /dev/pts/10
lrwx------ 1 agriffis agriffis 64 2009-01-28 20:29 1 -> /dev/pts/10
lrwx------ 1 agriffis agriffis 64 2009-01-28 20:29 2 -> /dev/pts/10
lr-x------ 1 agriffis agriffis 64 2009-01-28 20:29 3 -> /proc/12223/fd
l-wx------ 1 agriffis agriffis 64 2009-01-28 20:29 5 -> pipe:[13637]
lr-x------ 1 agriffis agriffis 64 2009-01-28 20:29 8 -> pipe:[42450591]

> urxvtd closes it's own file descriptors before executing
> programs within a temrinal, but it doesn't do anything to file
> descriptors unknowingly passed to it.

Okay, thanks.  I see now that it's true for a lot of processes:

$ ls -ld /proc/*/fd/8 2>/dev/null | grep -e '-> pipe:' | \
    awk -F/ '{print $3}' | grep -v '[^0-9]' | xargs ps

  PID TTY      STAT   TIME COMMAND
 4920 ?        Ss     0:00 gnome-power-manager --sm-config-prefix /gnome-po
11614 ?        S      0:00 /usr/lib/libgconf2-4/gconfd-2 12
11616 ?        S      0:00 /usr/bin/gnome-keyring-daemon -d --login
11675 ?        Ss     0:00 /usr/bin/gpg-agent --daemon --sh --write-env-fil
11678 ?        S      0:00 /usr/bin/dbus-launch --exit-with-session /home/a
11679 ?        Ss     0:00 /usr/bin/dbus-daemon --fork --print-pid 6 --prin
11711 ?        Sl     0:00 gnome-session
11839 ?        S      0:00 urxvtd -o -f -q
11857 ?        Ssl    0:00 gnome-settings-daemon
11866 ?        S      0:00 /usr/lib/gvfs/gvfsd
11882 ?        S      0:00 gnome-panel --sm-client-id default1
11886 ?        Ss     0:00 gnome-screensaver
11891 ?        Ssl    0:00 /usr/lib/bonobo-activation/bonobo-activation-ser
11899 ?        S      0:00 padevchooser
11911 ?        S      0:00 /usr/lib/gvfs/gvfs-hal-volume-monitor
11916 ?        S      0:00 /usr/lib/gvfs/gvfs-gphoto2-volume-monitor
11922 ?        Ss     0:00 gnome-power-manager
11926 ?        S      0:00 /usr/lib/byzanz/byzanz-applet --oaf-activate-iid
11929 ?        S      0:00 /usr/lib/gnome-applets/multiload-applet-2 --oaf-
11935 ?        Sl     0:00 /usr/lib/gnome-applets/mixer_applet2 --oaf-activ
11937 ?        S      0:00 /usr/lib/gnome-applets/gweather-applet-2 --oaf-a
11938 ?        S      0:00 /usr/lib/gnome-applets/cpufreq-applet --oaf-acti
11971 pts/9    Ss     0:00 bash
12090 pts/10   Ss     0:00 bash

However my window manager seems to close fds, so if I start new
urxvt processes instead of using urxvtc, 5 and 8 disappear.

Not sure yet what's leaving those fds open, but I'm guessing gdm
since I put a test prior to the /etc/X11/Xsession.d snippets and
they're already open then.

> most likely you start urxvtd with these file descriptors already open,
> then all processes started form urxvtd inherit them.

Yes, you're right.

Thanks,
Aron




More information about the rxvt-unicode mailing list