in reply to confusing fork/readline behaviour
Actually for reading they do share the same file descriptor. Try moving that open after the fork().
perl -e ' fork(); open X, "</etc/passwd"; while (readline(X)){ print "$$: $_"; sleep 1 } print "$$: all done\n" '
|
|---|