vfork and file-descriptors

vfork and file-descriptors

Post by Sowmini Varadh » Wed, 10 Apr 1996 04:00:00



Hi,

What happens to file-descriptors across a vfork? Am I correct in
assuming that since the file-descriptor is part of the Process Table,
it will continue to be duplicated (as in fork), even though the
parent and child executed in the same address space? Or should I
perform the dup myself?

Replies  by email would be preferred!

Thanks in advance,
--Sowmini

 
 
 

1. "Bad file descriptor" with Bash; how to designate descriptors?

I have a trivial script which tails multiple files by
spawning a 'tail' process for each file and duping the
output into one file descriptor which is then tailed:

  for f in $*; do
        tail -1f $f >&3 &
  done

  exec <&3
  tail -f

This works fine under Sun ksh, but I've just tried to run
it now with Bash under Linux 2.4.16, only to have each
command using file descriptor 3 fail with a

  'Bad file descriptor'

error.

This has caught me completely unawares.  The bash manpage
says that

  "If the digits in word do not specify a file descriptor open
  for output, a redirection error occurs"

How do I open file descriptor 3 for output?  Or, if I do
something like

  tail -1f file > /dev/null &

how can I find out what file descriptor is opened so I can
direct the output of further tail commands to the same
descriptor?  What's the magic that bash needs to be able to
do something like this?

Many thanks,

Brad

2. modem to modem file transfer?

3. Matrox Mystique ands X.

4. DNS setup

5. vfork.h file in linux?

6. diskette change after format?

7. portable way to convert FILE ptr to file descriptor?

8. Netscape and VGA X

9. how to get file length from file descriptor

10. *FILE and int as file descriptors.

11. Grabbing file from file descriptors

12. FILE descriptor and file id conversion?

13. difference b/w file pointer and file descriptor