develooper Front page | perl.perl5.porters | Postings from April 2006

[perl #38901] perlfaq8 correction

From:
srezic @ iconmobile . com
Date:
April 12, 2006 03:43
Subject:
[perl #38901] perlfaq8 correction
Message ID:
rt-3.0.11-38901-132182.1.48369537841084@perl.org
# New Ticket Created by  srezic@iconmobile.com 
# Please include the string:  [perl #38901]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org/rt3/Ticket/Display.html?id=38901 >



This is a bug report for perl from slavenr@devpc01.iconmobile.de,
generated with the help of perlbug 1.35 running under perl v5.8.7.


-----------------------------------------------------------------
About "How do I find out if I’m running interactively or not?":

The snippet with the solution for POSIX systems emits a die() if
/dev/tty cannot be opened. I think it should not die but rather
print "no tty". The situation that there's no /dev/tty can happen
on boot time on Linux systems.

So my suggestion is:

           use POSIX qw/getpgrp tcgetpgrp/;
           if (!open(TTY, "/dev/tty")) {
               print "no tty\n";
           } else {
               $tpgrp = tcgetpgrp(fileno(*TTY));
               $pgrp = getpgrp();
               if ($tpgrp == $pgrp) {
                   print "foreground\n";
               } else {
                   print "background\n";
               }
           }

Regards,
	Slaven

-----------------------------------------------------------------
---
Flags:
    category=docs
    severity=low
---
Site configuration information for perl v5.8.7:

Configured by slavenr at Fri Jul  8 12:48:31 CEST 2005.

Summary of my perl5 (revision 5 version 8 subversion 7) configuration:
  Platform:
    osname=linux, osvers=2.4.20-18.8, archname=i686-linux
    uname='linux devpc01.iconmobile.de 2.4.20-18.8 #1 thu may 29 08:57:39 edt 2003 i686 i686 i386 gnulinux '
    config_args='-ds -e -Dprefix=/usr/perl5.8.7'
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef
    useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
    use64bitint=undef use64bitall=undef uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='cc', ccflags ='-fno-strict-aliasing -pipe -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm',
    optimize='-O2',
    cppflags='-fno-strict-aliasing -pipe -I/usr/include/gdbm'
    ccversion='', gccversion='3.2 20020903 (Red Hat Linux 8.0 3.2-7)', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=4, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -L/usr/local/lib'
    libpth=/usr/local/lib /lib /usr/lib
    libs=-lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lc
    perllibs=-lnsl -ldl -lm -lcrypt -lutil -lc
    libc=/lib/libc-2.2.93.so, so=so, useshrplib=false, libperl=libperl.a
    gnulibc_version='2.2.93'
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E'
    cccdlflags='-fpic', lddlflags='-shared -L/usr/local/lib'

Locally applied patches:
    

---
@INC for perl v5.8.7:
    /usr/perl5.8.7/lib/5.8.7/i686-linux
    /usr/perl5.8.7/lib/5.8.7
    /usr/perl5.8.7/lib/site_perl/5.8.7/i686-linux
    /usr/perl5.8.7/lib/site_perl/5.8.7
    /usr/perl5.8.7/lib/site_perl
    .

---
Environment for perl v5.8.7:
    HOME=/home/slavenr
    LANG=en_US.UTF-8
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/usr/local/mysql-max-5.0.15-linux-i686/bin:/usr/local/netpbm/bin:/usr/X11R6/bin:/usr/X11/bin:/usr/perl5.8.0/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/usr/local/pilot/bin:/home/slavenr/bin/linux-gnu:/home/slavenr/bin/sh:/home/slavenr/bin:/usr/X386/bin:/usr/games:/home/slavenr/devel:/epoc/nokia60/epoc32/tools:/usr/local/er6/bin/:/home/slavenr/work/clientframework/perl/bin/:/usr/java/jdk/bin:/usr/java/ant/bin
    PERL_BADLANG (unset)
    PERL_HTML_DISPLAY_CLASS=HTML::Display::Mozilla
    SHELL=/usr/local/bin/zsh




nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About