summaryrefslogtreecommitdiff
path: root/pod/perlfaq8.pod
diff options
context:
space:
mode:
authorSteve Peters <steve@fisharerojo.org>2006-04-19 16:32:26 +0000
committerSteve Peters <steve@fisharerojo.org>2006-04-19 16:32:26 +0000
commit3ab9de8d44d3d74d1d2cd86d04a174461ff819fa (patch)
tree3bad2b77624d9987560fdf887c13c6ade4b419e3 /pod/perlfaq8.pod
parent5a7dac4e435401addc047693f17f4d91177e2254 (diff)
downloadperl-3ab9de8d44d3d74d1d2cd86d04a174461ff819fa.tar.gz
Changes to perlfaq8 "How do I find out if I'm running interactively
or not?" suggested by Slaven Rezic in RT #38901: perlfaq8 correction p4raw-id: //depot/perl@27905
Diffstat (limited to 'pod/perlfaq8.pod')
-rw-r--r--pod/perlfaq8.pod18
1 files changed, 12 insertions, 6 deletions
diff --git a/pod/perlfaq8.pod b/pod/perlfaq8.pod
index 06494e240f..d5c63daa29 100644
--- a/pod/perlfaq8.pod
+++ b/pod/perlfaq8.pod
@@ -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?