bug-gawk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug-gawk] gawk and inherited file descriptors


From: Howard Bryden
Subject: [bug-gawk] gawk and inherited file descriptors
Date: Mon, 2 Nov 2015 06:19:15 +0000

Guys,

 

I'm using gawk 4.1.3 under HP-UX 11.31 (POSIX shell) and I wonder if I'm missing something.

 

The shell fragment

 

exec 9<&1

ls –l | gawk '{ print >"/dev/fd/9" }'

 

is intended to send its output to fd 9, dup'ed from stdout.  Yet I get

 

gawk: cmd. line:2: (FILENAME=- FNR=1) fatal: can't redirect to `/dev/fd/9' (No such file or directory)

 

 

Using lsof to see what the child process has available:

 

bnetst03:/tmp # cat x

exec 9<&1

ls -l | gawk '

BEGIN   { system( "lsof -p " PROCINFO["pid"] ) }

        { print $0 >"/dev/fd/9" }'

bnetst03:/tmp # ./x

COMMAND   PID USER   FD   TYPE             DEVICE SIZE/OFF   NODE NAME

gawk    13565 root  cwd    DIR             64,0x6     8192      2 /tmp

gawk    13565 root  txt    REG             64,0x7  1740108  16209 /usr/local/bin/gawk

gawk    13565 root  mem    REG             64,0x7  5026568  13064 /usr/lib/hpux32/libc.so.1

gawk    13565 root  mem    REG             64,0x7  6357576  42868 /usr/lib/hpux32/libm.so.1

gawk    13565 root  mem    REG             64,0x7   191412  42988 /usr/lib/hpux32/uld.so

gawk    13565 root  mem    REG             64,0x7    76736  42986 /usr/lib/hpux32/libdl.so.1

gawk    13565 root  mem    REG             64,0x7  1170156  42985 /usr/lib/hpux32/dld.so

gawk    13565 root    0r  FIFO 0xe00000054d5ce888      0t0 540953

gawk    13565 root    1u   STR            157,0x1  0t29131    696 /dev/pts/1->ldterm->ptem->pts

gawk    13565 root    2u   STR            157,0x1  0t29131    696 /dev/pts/1->ldterm->ptem->pts

gawk: cmd. line:3: (FILENAME=- FNR=1) fatal: can't redirect to `/dev/fd/9' (No such file or directory)

bnetst03:/tmp #

 

it seems that fd 9, which should have been inherited, is not picked up at all.

 

Now this script actually works under Cygwin (awk 4.1.0) and RHEL (bash 3.0.15, awk 3.1.3).  Moreover, the HP POSIX shell itself seems to quite happily pass descriptors to child shells:

 

bnetst03:/tmp # cat x

exec 9<&1

ls -l | ./x2

bnetst03:/tmp # cat x2

cat >&9

bnetst03:/tmp # ./x

total 64

drwxrwxrwx   2 root       sys             96 Oct 16 14:07 !p4.d

drwx------   2 root       root            96 Oct 13 08:41 .AgentSockets

-rw-rw-rw-   1 root       sys            128 Oct 13 14:35 .kc.trace

drwx------   2 root       root            96 Oct 13 08:52 .mcsg

srwxrwxrwx   1 sfmdb      users            0 Nov  2 15:34 .s.PGSQL.10864

-rw-------   1 sfmdb      users           27 Nov  2 15:34 .s.PGSQL.10864.lock

drwx------   2 root       sys             96 Oct 20 14:34 d

-rw-r--r--   1 root       root             0 Oct 13 08:41 ipv6agt.crashlog

-r--r--r--   1 root       root             0 Oct 13 08:41 llbdbase.dat

drwxr-xr-x   2 root       root            96 Nov 11  2013 lost+found

-rwx------   1 root       sys            113 Nov  2 16:13 x

-rwx------   1 root       sys              8 Nov  2 15:55 x2

bnetst03:/tmp #

 

 

Is there something Not Quite Right with the HP-UX build of gawk ?

 

Thanks.

 

                                                                         
Rocket J. Squirrel: "... we're going to have to think!"
Bullwinkle J. Moose: "There must be an easier way than that."

HOWARD BRYDEN
                                                                          
Senior Unix Administrator
Infrastructure Support
Public Safety Business Agency
                                                                          
PHONE: 07 3635 3087
POSTAL: GPO Box 1425, Brisbane, QLD 4001 | EMAIL: address@hidden

 

cid:image001.jpg@01CF9486.DD35C1D0     cid:image003.jpg@01CF8FBC.3E77B590    

 

 


This correspondence is for the named persons only. It may contain confidential or privileged information or both. No confidentiality or privilege is waived or lost by any mis transmission. If you receive this correspondence in error please delete it from your system immediately and notify the sender. You must not disclose, copy or relay on any part of this correspondence, if you are not the intended recipient. Any opinions expressed in this message are those of the individual sender except where the sender expressly, and with the authority, states them to be the opinions of the Queensland Government.
All reasonable precautions will be taken to respect the privacy of individuals in accordance with the Information Privacy Act 2009 (Qld).


reply via email to

[Prev in Thread] Current Thread [Next in Thread]