Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

csh/tcsh closing FD's?

0 views
Skip to first unread message

Paul D. Smith

unread,
Jul 2, 2001, 5:49:23 PM7/2/01
to
Someone has reported this interesting "feature" of csh and tcsh, and
I've confirmed it; I wonder if anyone has any thoughts on this, most
particularly ways to avoid it.

It seems that if you have a program, and it opens some file descriptors
(in my case, a regular pipe), then you fork/exec either a csh or tcsh
script, that csh/tcsh will _close_ your file descriptors (note they
are _not_ marked as close on exec--the same sequence works fine with
Bourne shells).

I note that Tom Christiansen's "Csh Programming Considered Harmful"
says:

The csh has also been known to close all open file descriptors besides
the ones it knows about, making it unsuitable for applications that
intend to inherit open file descriptors.

which tends to confirm my observations (I tested with csh from Solaris
7, and tcsh 6.09.03 from my Debian GNU/Linux distro).

Does anyone know of a way to _stop_ C shells from doing this?


Personally, I'm happy to tell people to not use C shell, but if there is
a way to fix this I feel I have an obligation to share it :).

--
-------------------------------------------------------------------------------
Paul D. Smith <psm...@gnu.org> Find some GNU make tips at:
http://www.gnu.org http://www.paulandlesley.org/gmake/
"Please remain calm...I may be mad, but I am a professional." --Mad Scientist

Keith Thompson

unread,
Jul 3, 2001, 4:51:02 PM7/3/01
to
"Paul D. Smith" <psm...@gnu.org> writes:
> Someone has reported this interesting "feature" of csh and tcsh, and
> I've confirmed it; I wonder if anyone has any thoughts on this, most
> particularly ways to avoid it.
>
> It seems that if you have a program, and it opens some file descriptors
> (in my case, a regular pipe), then you fork/exec either a csh or tcsh
> script, that csh/tcsh will _close_ your file descriptors (note they
> are _not_ marked as close on exec--the same sequence works fine with
> Bourne shells).
>
> I note that Tom Christiansen's "Csh Programming Considered Harmful"
> says:
>
> The csh has also been known to close all open file descriptors besides
> the ones it knows about, making it unsuitable for applications that
> intend to inherit open file descriptors.
>
> which tends to confirm my observations (I tested with csh from Solaris
> 7, and tcsh 6.09.03 from my Debian GNU/Linux distro).
>
> Does anyone know of a way to _stop_ C shells from doing this?

Quick answer: I don't know.

The tcsh sources are available (I don't recall what license it uses),
so if you can find the code that does this, you should be able to turn
off the feature, or perhaps even find out how to disable it
dynamically. You can also submit or suggest a fix to the maintainer
for future releases. (Is there a reason for this feature? Would
just removing it break anything?)

Of course, this doesn't do any good for csh or (probably) for existing
versions of tcsh.

--
Keith Thompson (The_Other_Keith) k...@cts.com <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://www.sdsc.edu/~kst>
Cxiuj via bazo apartenas ni.

Ari Makela

unread,
Jul 3, 2001, 6:39:13 PM7/3/01
to
Keith Thompson <k...@cts.com> writes:

> The tcsh sources are available (I don't recall what license it uses),

The old BSD licence i.e. with the advertisentment clause.

The version of tcsh being

$ dpkg --status tcsh | egrep '^Version: '
Version: 6.09.00-10

--
#!/usr/bin/perl -w -- Ari Makela <ha...@iki.fi> #
# http://arska.org/hauva/ #

print "Navigare necesse est, vivere non est necesse - Pompeius\n";

Keith Thompson

unread,
Jul 4, 2001, 5:37:38 AM7/4/01
to
Ari Makela <ha...@iki.fi> writes:
> Keith Thompson <k...@cts.com> writes:
> > The tcsh sources are available (I don't recall what license it uses),
>
> The old BSD licence i.e. with the advertisentment clause.
>
> The version of tcsh being
>
> $ dpkg --status tcsh | egrep '^Version: '
> Version: 6.09.00-10

FYI, the latest release on ftp.astron.com is 6.10.00.

0 new messages