X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=pod%2Fperlfaq8.pod;h=d5c63daa29788fae93da90d53e5c967636af071a;hb=3b910f1cdd4f8ae1cc44d538e0b3182f132b4bf7;hp=55c3cbf8996113404576b4fd7a279e52c2b160c0;hpb=58103a2e295c15d87c7ce0bd8dd83d7e110adac4;p=p5sagit%2Fp5-mst-13.2.git diff --git a/pod/perlfaq8.pod b/pod/perlfaq8.pod index 55c3cbf..d5c63da 100644 --- a/pod/perlfaq8.pod +++ b/pod/perlfaq8.pod @@ -1,6 +1,6 @@ =head1 NAME -perlfaq8 - System Interaction ($Revision: 1.27 $, $Date: 2005/12/31 00:54:37 $) +perlfaq8 - System Interaction ($Revision: 3606 $) =head1 DESCRIPTION @@ -666,8 +666,8 @@ files: use IPC::Open3; use Symbol qw(gensym); use IO::File; - local *CATCHOUT = IO::File->new_tempfile; - local *CATCHERR = IO::File->new_tempfile; + local *CATCHOUT = IO::File->new_tmpfile; + local *CATCHERR = IO::File->new_tmpfile; my $pid = open3(gensym, ">&CATCHOUT", ">&CATCHERR", "cmd"); waitpid($pid, 0); seek $_, 0, 0 for \*CATCHOUT, \*CATCHERR; @@ -680,7 +680,7 @@ should work just as well, without deadlocking: use IPC::Open3; use Symbol qw(gensym); use IO::File; - local *CATCHERR = IO::File->new_tempfile; + local *CATCHERR = IO::File->new_tmpfile; my $pid = open3(gensym, \*CATCHOUT, ">&CATCHERR", "cmd"); while( ) {} waitpid($pid, 0); @@ -1005,13 +1005,19 @@ On POSIX systems, you can test whether your own process group matches the current process group of your controlling terminal as follows: use POSIX qw/getpgrp tcgetpgrp/; - open(TTY, "/dev/tty") or die $!; - $tpgrp = tcgetpgrp(fileno(*TTY)); - $pgrp = getpgrp(); - if ($tpgrp == $pgrp) { - print "foreground\n"; + + # Some POSIX systems, such as Linux, can be + # without a /dev/tty at boot time. + if (!open(TTY, "/dev/tty")) { + print "no tty\n"; } else { - print "background\n"; + $tpgrp = tcgetpgrp(fileno(*TTY)); + $pgrp = getpgrp(); + if ($tpgrp == $pgrp) { + print "foreground\n"; + } else { + print "background\n"; + } } =head2 How do I timeout a slow event? @@ -1251,6 +1257,14 @@ It's a perl4-style file defining values for system networking constants. Sometimes it is built using h2ph when Perl is installed, but other times it is not. Modern programs C instead. +=head1 REVISION + +Revision: $Revision: 3606 $ + +Date: $Date: 2006-03-06 12:05:47 +0100 (lun, 06 mar 2006) $ + +See L for source control details and availability. + =head1 AUTHOR AND COPYRIGHT Copyright (c) 1997-2006 Tom Christiansen, Nathan Torkington, and