Re: bad file descriptor in ksh but not in bash
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Unix and Linux reviews > Free Debian support > Linux Debian support > Re: bad file descriptor in ksh but not in bash




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    Re: bad file descriptor in ksh but not in bash  
Michael Paoli


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
04-18-06 05:12 AM

M=2E =C5hman wrote:
> On 12 Apr 2006 08:08:32 -0700
> "Michael Paoli" <michael1cat@yahoo.com> wrote: 
> Found it in pdksh's man page:
Ah, ... good catch :-) ... and even a fairly logically place for it.
> exec [command [arg ...]]
>     If no command is given except for I/O redirection, the I/O redi-
>     rection is permanent and the shell is not replaced.  Any file
>     de- scriptors greater than 2 which are opened or dup(2)'d in
>     this way are not made available to other executed commands (i.e.
>     commands that are not built-in to the shell).  Note that the
>     Bourne shell differs here; it does pass these file descriptors
>     on.
I also note my ksh(1)/pdksh(1) also includes, right below that:
(DEBIAN  NOTE: when the shell is called as /bin/sh, it does pass these
file descriptors on, like the Bourne shell.)

Now, I wonder if arg0 needs to litterally be /bin/sh, or if it
suffices for arg0 to have a basename of sh or -sh, or perhaps even just
starting with one of those sets of characters in the basename portion.

Ah yes, the documentation isn't precisely correct:
$ PERL -e 'exec {q(/bin/ksh)} (q(/bin/sh),q(-c),q(exec 6>foo; sh -c
'''echo foo >&6'''));'
$ PERL -e 'exec {q(/bin/ksh)} (q(sh),q(-c),q(exec 6>foo; sh -c '''echo
foo >&6'''));'
$ PERL -e 'exec {q(/bin/ksh)} (q(-sh),q(-c),q(exec 6>foo; sh -c
'''echo foo >&6'''));'
$ PERL -e 'exec {q(/bin/ksh)} (q(-ksh),q(-c),q(exec 6>foo; sh -c
'''echo foo >&6'''));'
sh: line 1: 6: Bad file descriptor
$ PERL -e 'exec {q(/bin/ksh)} (q(/bin/ksh),q(-c),q(exec 6>foo; sh -c
'''echo foo >&6'''));'
sh: line 1: 6: Bad file descriptor
$ PERL -e 'exec {q(/bin/ksh)} (q(shooflyshoo),q(-c),q(exec 6>foo; sh -c
'''echo foo >&6'''));'
sh: line 1: 6: Bad file descriptor
$ PERL -e 'exec {q(/bin/ksh)} (q(/foo/bar/baz/sh),q(-c),q(exec 6>foo;
sh -c '''echo foo >&6'''));'
$
It looks like it probably checks for a basename portion of arg0 of sh
or -sh, with perhaps some additional possibilities.

When in doubt, test and/or use the source :-)






[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 02:08 AM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register