develooper Front page | perl.perl5.porters | Postings from March 2008

[perl #51642] waitpid() example in perlfunc(1) is bogus

Thread Next
From:
vedge @ hypertriton . com
Date:
March 12, 2008 09:49
Subject:
[perl #51642] waitpid() example in perlfunc(1) is bogus
Message ID:
rt-3.6.HEAD-25460-1205318965-1760.51642-75-0@perl.org
# New Ticket Created by  vedge@hypertriton.com 
# Please include the string:  [perl #51642]
# in the subject line of all future correspondence about this issue. 
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=51642 >



This is a bug report for perl from vedge@hypertriton.com,
generated with the help of perlbug 1.35 running under perl v5.8.8.


-----------------------------------------------------------------
perlfunc(1) gives the following example for waitpid() usage:

	use POSIX ":sys_wait_h";
	#...
	do {
	    $kid = waitpid(-1, WNOHANG);
	} while $kid > 0;

This would obviously cause an infinite loop as waitpid() returns
-1 only when there are no more child processes to wait on. The
correct usage would be:

	use POSIX ":sys_wait_h";
	#...
	do {
	    $kid = waitpid(-1, WNOHANG);
	} while $kid != -1;

[Please do not change anything below this line]
-----------------------------------------------------------------
---
Flags:
    category=docs
    severity=medium
---
Site configuration information for perl v5.8.8:

Configured by root at Thu Jan  1  0:00:00 UTC 1970.

Summary of my perl5 (revision 5 version 8 subversion 8) configuration:
  Platform:
    osname=openbsd, osvers=4.2, archname=amd64-openbsd
    uname='openbsd'
    config_args='-dsE -Dopenbsd_distribution=defined'
    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=define use64bitall=define uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='cc', ccflags ='-fno-strict-aliasing -fno-delete-null-pointer-checks -pipe -I/usr/local/include',
    optimize='-O2',
    cppflags='-fno-strict-aliasing -fno-delete-null-pointer-checks -pipe -I/usr/local/include'
    ccversion='', gccversion='3.3.5 (propolice)', gccosandvers='openbsd4.2'
    intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
    ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=8, prototype=define
  Linker and Libraries:
    ld='cc', ldflags ='-Wl,-E '
    libpth=/usr/lib
    libs=-lm -lutil -lc
    perllibs=-lm -lutil -lc
    libc=/usr/lib/libc.a, so=so, useshrplib=true, libperl=libperl.so.10.1
    gnulibc_version=''
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-R/usr/libdata/perl5/amd64-openbsd/5.8.8/CORE'
    cccdlflags='-DPIC -fPIC ', lddlflags='-shared -fPIC '

Locally applied patches:
    

---
@INC for perl v5.8.8:
    /usr/libdata/perl5/amd64-openbsd/5.8.8
    /usr/local/libdata/perl5/amd64-openbsd/5.8.8
    /usr/libdata/perl5
    /usr/local/libdata/perl5
    /usr/local/libdata/perl5/site_perl/amd64-openbsd
    /usr/libdata/perl5/site_perl/amd64-openbsd
    /usr/local/libdata/perl5/site_perl
    /usr/libdata/perl5/site_perl
    /usr/local/lib/perl5/site_perl
    .

---
Environment for perl v5.8.8:
    HOME=/home/vedge
    LANG (unset)
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/home/vedge/bin:/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin:/sbin:/usr/games:/usr/sbin:/usr/local/sbin
    PERL_BADLANG (unset)
    SHELL=/bin/bash


Thread Next


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