Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PATCH] Improve documentation to support portability #11379

Closed
p5pRT opened this issue May 24, 2011 · 20 comments
Closed

[PATCH] Improve documentation to support portability #11379

p5pRT opened this issue May 24, 2011 · 20 comments
Labels

Comments

@p5pRT
Copy link

p5pRT commented May 24, 2011

Migrated from rt.perl.org#91526 (status was 'resolved')

Searchable as RT91526$

@p5pRT
Copy link
Author

p5pRT commented May 24, 2011

From Bo.Johansson@lsn.se

From be5ca44137a6934c3360c55b259706be328e368e Mon Sep 17 00​:00​:00 2001
From​: bojilund <bo.johansso@​lsn.se>
Date​: Tue, 24 May 2011 15​:27​:44 +0200

To write portable Perl code there are many things to consider.
Portability issues are dealt with in separate documents or sections
and this make programmers working on the reference platform
(Unix/Linux) less aware of problems in other platforms.

This patch​:

1) Adds information about portability issues in the
"Alphabetical Listing of Perl Functions" in perlfunc.pod.

2) In perlfork.pod adds a section about kill on forked
processes in portable Perl code.


pod/perlfork.pod | 12 +++++
pod/perlfunc.pod | 134 ++++++++++++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 143 insertions(+), 3 deletions(-)

Inline Patch
diff --git a/pod/perlfork.pod b/pod/perlfork.pod
index 709d053..4eeab97 100644
--- a/pod/perlfork.pod
+++ b/pod/perlfork.pod
@@ -307,6 +307,18 @@ are expected to be fixed for thread-safety.

=back

+=head1 PORTABLE PERL CODE AND KILL OF FORKED PROCESSES
+
+In portable Perl code, kill(9, $child) must not be used on forked processes.
+
+Forked process are in Windows implemented as a pseudo-processes.
+To use kill(9, $child) on pseudo-processes is unsafe.
+The process which implements the pseudo-processes can be blocked and the Perl interpreter hangs.
+
+The outcome of kill on a pseudo-process is unpredictable.
+It depends on the timing in the Windows operating system.
+Code that has worked, suddenly can fail, resulting in errors which are difficult to find.
+
=head1 BUGS

=over 8

Inline Patch
diff --git a/pod/perlfunc.pod b/pod/perlfunc.pod
index 91a19a2..91ab03e 100644
--- a/pod/perlfunc.pod
+++ b/pod/perlfunc.pod
@@ -430,6 +430,8 @@ C<-x $file && -w _ && -f _>. (This is only fancy fancy: if you use
the return value of C<-f $file> as an argument to another filetest operator\, no special magic will happen\.\)

+Portability issues​: L<perlport/x>.
+
=item abs VALUE
X<abs> X<absolute>

@​@​ -500,6 +502,8 @​@​ modulo the caveats given in L<perlipc/"Signals">.

For more information see L<perlipc>.

+Portability issues​: L<perlport/alarm>.
+
=item atan2 Y,X
X<atan2> X<arctangent> X<tan> X<tangent>

@​@​ -513,6 +517,8 @​@​ function, or use the familiar relation​:
The return value for C<atan2(0,0)> is implementation-defined; consult
your atan2(3) manpage for more information.

+Portability issues​: L<perlport/atan2>.
+
=item bind SOCKET,NAME
X<bind>

@​@​ -612,6 +618,8 @​@​ but also when using read(), seek(), sysread(), syswrite() and tell()
in L<perlvar> for how to manually set your input and output
line-termination sequences.

+Portability issues​: L<perlport/binmode>.
+
=item bless REF,CLASSNAME
X<bless>

@​@​ -761,6 +769,8 @​@​ module​:
  chmod S_IRWXU|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH, @​executables;
  # Identical to the chmod 0755 of the example above.

+Portability issues​: L<perlport/chmod>.
+
=item chomp VARIABLE
X<chomp> X<INPUT_RECORD_SEPARATOR> X<$/> X<newline> X<eol>

@​@​ -864,6 +874,8 @​@​ On POSIX systems, you can detect this condition this way​:
  use POSIX qw(sysconf _PC_CHOWN_RESTRICTED);
  $can_chown_giveaway = not sysconf(_PC_CHOWN_RESTRICTED);

+Portability issues​: L<perlport/chmod>.
+
=item chr NUMBER
X<chr> X<character> X<ASCII> X<Unicode>

@​@​ -898,6 +910,8 @​@​ change your current working directory, which is unaffected.) For security
reasons, this call is restricted to the superuser. If FILENAME is
omitted, does a C<chroot> to C<$_>.

+Portability issues​: L<perlport/chroot>.
+
=item close FILEHANDLE
X<close>

@​@​ -1089,6 +1103,8 @​@​ the string back to an eight-bit byte string before calling crypt()
(on that copy). If that works, good. If not, crypt() dies with
C<Wide character in crypt>.

+Portability issues​: L<perlport/crypt>.
+
=item dbmclose HASH
X<dbmclose>

@​@​ -1096,6 +1112,8 @​@​ X<dbmclose>

Breaks the binding between a DBM file and a hash.

+Portability issues​: L<perlport/dbmclose>.
+
=item dbmopen HASH,DBNAME,MASK
X<dbmopen> X<dbm> X<ndbm> X<sdbm> X<gdbm>

@​@​ -1139,6 +1157,8 @​@​ before you call dbmopen()​:
  dbmopen(%NS_Hist, "$ENV{HOME}/.netscape/history.db")
  or die "Can't open netscape history file​: $!";

+Portability issues​: L<perlport/dbmopen>.
+
=item default BLOCK

Within a C<foreach> or a C<given>, a C<default> BLOCK acts like a C<when>
@​@​ -1475,6 +1495,8 @​@​ convert a core file into an executable. That's why you should now invoke
it as C<CORE​::dump()>, if you don't want to be warned against a possible
typo.

+Portability issues​: L<perlport/dump>.
+
=item each HASH
X<each> X<hash, iterator>

@​@​ -1802,6 +1824,8 @​@​ open handles to avoid lost output.
Note that C<exec> will not call your C<END> blocks, nor will it invoke
C<DESTROY> methods on your objects.

+Portability issues​: L<perlport/exec>.
+
=item exists EXPR
X<exists> X<autovivification>

@​@​ -1896,6 +1920,8 @​@​ can change the exit status by modifying C<$?>. If this is a problem, you
can call C<POSIX​:_exit($status)> to avoid END and destructor processing.
See L<perlmod> for details.

+Portability issues​: L<perlport/exit>.
+
=item exp EXPR
X<exp> X<exponential> X<antilog> X<antilogarithm> X<e>

@​@​ -1941,6 +1967,8 @​@​ on your own, though.
  $flags = fcntl(REMOTE, F_SETFL, $flags | O_NONBLOCK)
  or die "Can't set flags for the socket​: $!\n";

+Portability issues​: L<perlport/fcntl>.
+
=item fileno FILEHANDLE
X<fileno>

@​@​ -2041,6 +2069,8 @​@​ function lose their locks, making it seriously harder to write servers.

See also L<DB_File> for other flock() examples.

+Portability issues​: L<perlport/flock>.
+
=item fork
X<fork> X<child> X<parent>

@​@​ -2070,6 +2100,14 @​@​ if you exit, then the remote server (such as, say, a CGI script or a
backgrounded job launched from a remote shell) won't think you're done.
You should reopen those to F</dev/null> if it's any issue.

+On some platforms such as Windows, where the fork() system call is not available,
+Perl can be built to emulate fork() in the Perl interpreter. The emulation is designed to,
+at the level of the Perl program, be as compatible as possible with the "Unix" fork().
+However it has limitation that has to be considered in code intended to be portable.
+See L<perlfork> for more details.
+
+Portability issues​: L<perlport/fork>.
+
=item format
X<format>

@​@​ -2161,6 +2199,8 @​@​ returns the empty string, use C<getpwuid>.
Do not consider C<getlogin> for authentication​: it is not as
secure as C<getpwuid>.

+Portability issues​: L<perlport/getlogin>.
+
=item getpeername SOCKET
X<getpeername> X<peer>

@​@​ -2183,6 +2223,8 @​@​ doesn't implement getpgrp(2). If PID is omitted, returns the process
group of the current process. Note that the POSIX version of C<getpgrp>
does not accept a PID argument, so only C<PID==0> is truly portable.

+Portability issues​: L<perlport/getpgrp>.
+
=item getppid
X<getppid> X<parent> X<pid>

@​@​ -2195,6 +2237,8 @​@​ C<getppid()>, that returns a consistent value across threads. If you want
to call the underlying C<getppid()>, you may use the CPAN module
C<Linux​::Pid>.

+Portability issues​: L<perlport/getppid>.
+
=item getpriority WHICH,WHO
X<getpriority> X<priority> X<nice>

@​@​ -2202,6 +2246,8 @​@​ Returns the current priority for a process, a process group, or a user.
(See C<getpriority(2)>.) Will raise a fatal exception if used on a
machine that doesn't implement getpriority(2).

+Portability issues​: L<perlport/getpriority>.
+
=item getpwnam NAME
X<getpwnam> X<getgrnam> X<gethostbyname> X<getnetbyname> X<getprotobyname>
X<getpwuid> X<getgrgid> X<getservbyname> X<gethostbyaddr> X<getnetbyaddr>
@​@​ -2373,6 +2419,8 @​@​ Even though it looks as though they're the same method calls (uid),
they aren't, because a C<File​::stat> object is different from
a C<User​::pwent> object.

+Portability issues​: L<perlport/getpwnam> to L<perlport/endservent>.
+
=item getsockname SOCKET
X<getsockname>

@​@​ -2418,6 +2466,7 @​@​ Here's an example to test whether Nagle's algorithm is enabled on a socket​:
  my $nodelay = unpack("I", $packed);
  print "Nagle's algorithm is turned ", $nodelay ? "off\n" : "on\n";

+Portability issues​: L<perlport/getsockopt>.

=item given EXPR BLOCK
X<given>
@​@​ -2472,6 +2521,8 @​@​ Beginning with v5.6.0, this operator is implemented using the standard
C<File​::Glob> extension. See L<File​::Glob> for details, including
C<bsd_glob> which does not treat whitespace as a pattern separator.

+Portability issues​: L<perlport/glob>.
+
=item gmtime EXPR
X<gmtime> X<UTC> X<Greenwich>

@​@​ -2484,7 +2535,7 @​@​ Note​: When called in list context, $isdst, the last value
returned by gmtime, is always C<0>. There is no
Daylight Saving Time in GMT.

-See L<perlport/gmtime> for portability concerns.
+Portability issues​: L<perlport/gmtime>.

=item goto LABEL
X<goto> X<jump> X<jmp>
@​@​ -2661,6 +2712,8 @​@​ system​:
The special string C<"0 but true"> is exempt from B<-w> complaints
about improper numeric conversions.

+Portability issues​: L<perlport/ioctl>.
+
=item join EXPR,LIST
X<join>

@​@​ -2771,6 +2824,15 @​@​ signal the current process group and -1 will signal all processes.

See L<perlipc/"Signals"> for more details.

+On some platforms such as Windows where the fork() system call is not available.
+Perl can be built to emulate fork() at the interpreter level.
+This emulation has limitation related to kill that has to be considered,
+for code running on Windows and in code intended to be portable.
+
+See L<perlfork> for more details.
+
+Portability issues​: L<perlport/kill>.
+
=item last LABEL
X<last> X<break>

@​@​ -2897,6 +2959,8 @​@​ X<link>
Creates a new filename linked to the old filename. Returns true for
success, false otherwise.

+Portability issues​: L<perlport/link>.
+
=item listen SOCKET,QUEUESIZE
X<listen>

@​@​ -2990,8 +3054,6 @​@​ try for example​:
Note that the C<%a> and C<%b>, the short forms of the day of the week
and the month of the year, may not necessarily be three characters wide.

-See L<perlport/localtime> for portability concerns.
-
The L<Time​::gmtime> and L<Time​::localtime> modules provide a convenient,
by-name access mechanism to the gmtime() and localtime() functions,
respectively.
@​@​ -2999,6 +3061,8 @​@​ respectively.
For a comprehensive date and time representation look at the
L<DateTime> module on CPAN.

+Portability issues​: L<perlport/localtime>.
+
=item lock THING
X<lock>

@​@​ -3041,6 +3105,8 @​@​ information, please see the documentation for C<stat>.

If EXPR is omitted, stats C<$_>.

+Portability issues​: L<perlport/lstat>.
+
=item m//

The match operator. See L<perlop/"Regexp Quote-Like Operators">.
@​@​ -3165,6 +3231,8 @​@​ C<"0 but true"> for zero, or the actual return value otherwise. See also
L<perlipc/"SysV IPC"> and the documentation for C<IPC​::SysV> and
C<IPC​::Semaphore>.

+Portability issues​: L<perlport/msgctl>.
+
=item msgget KEY,FLAGS
X<msgget>

@​@​ -3173,6 +3241,8 @​@​ id, or C<undef> on error. See also
L<perlipc/"SysV IPC"> and the documentation for C<IPC​::SysV> and
C<IPC​::Msg>.

+Portability issues​: L<perlport/msgget>.
+
=item msgrcv ID,VAR,SIZE,TYPE,FLAGS
X<msgrcv>

@​@​ -3185,6 +3255,8 @​@​ Taints the variable. Returns true if successful, false
on error. See also L<perlipc/"SysV IPC"> and the documentation for
C<IPC​::SysV> and C<IPC​::SysV​::Msg>.

+Portability issues​: L<perlport/msgrcv>.
+
=item msgsnd ID,MSG,FLAGS
X<msgsnd>

@​@​ -3196,6 +3268,8 @​@​ C<pack("l! a*", $type, $message)>. Returns true if successful,
false on error. See also the C<IPC​::SysV>
and C<IPC​::SysV​::Msg> documentation.

+Portability issues​: L<perlport/msgsnd>.
+
=item my EXPR
X<my>

@​@​ -3705,6 +3779,8 @​@​ yourself and inspect the return value.

See L</seek> for some details about mixing reading and writing.

+Portability issues​: L<perlport/open>.
+
=item opendir DIRHANDLE,EXPR
X<opendir>

@​@​ -4823,6 +4899,8 @​@​ implemented. If not, raises an exception. If there is a system
error, returns the undefined value and sets C<$!> (errno). If EXPR is
omitted, uses C<$_>.

+Portability issues​: L<perlport/readlink>.
+
=item readpipe EXPR

=item readpipe
@​@​ -4956,6 +5034,8 @​@​ rename(2) manpage or equivalent system documentation for details.
For a platform independent C<move> function look at the L<File​::Copy>
module.

+Portability issues​: L<perlport/rename>.
+
=item require VERSION
X<require>

@​@​ -5216,6 +5296,8 @​@​ X<rewinddir>
Sets the current position to the beginning of the directory for the
C<readdir> routine on DIRHANDLE.

+Portability issues​: L<perlport/rewinddir>.
+
=item rindex STR,SUBSTR,POSITION
X<rindex>

@​@​ -5374,6 +5456,8 @​@​ methods, preferring to write the last example as​:
  use IO​::Handle;
  STDERR->autoflush(1);

+Portability issues​: L<perlport/select>.
+
=item select RBITS,WBITS,EBITS,TIMEOUT
X<select>

@​@​ -5438,6 +5522,8 @​@​ B<WARNING>​: One should not attempt to mix buffered I/O (like C<read>
or <FH>) with C<select>, except as permitted by POSIX, and even
then only on POSIX systems. You have to use C<sysread> instead.

+Portability issues​: L<perlport/select>.
+
=item semctl ID,SEMNUM,CMD,ARG
X<semctl>

@​@​ -5454,6 +5540,8 @​@​ short integers, which may be created with C<pack("s!",(0)x$nsem)>.
See also L<perlipc/"SysV IPC">, C<IPC​::SysV>, C<IPC​::Semaphore>
documentation.

+Portability issues​: L<perlport/semctl>.
+
=item semget KEY,NSEMS,FLAGS
X<semget>

@​@​ -5462,6 +5550,8 @​@​ the undefined value on error. See also
L<perlipc/"SysV IPC">, C<IPC​::SysV>, C<IPC​::SysV​::Semaphore>
documentation.

+Portability issues​: L<perlport/semget>.
+
=item semop KEY,OPSTRING
X<semop>

@​@​ -5480,6 +5570,8 @​@​ To signal the semaphore, replace C<-1> with C<1>. See also
L<perlipc/"SysV IPC">, C<IPC​::SysV>, and C<IPC​::SysV​::Semaphore>
documentation.

+Portability issues​: L<perlport/semop>.
+
=item send SOCKET,MSG,FLAGS,TO
X<send>

@​@​ -5510,6 +5602,8 @​@​ it defaults to C<0,0>. Note that the BSD 4.2 version of C<setpgrp> does not
accept any arguments, so only C<setpgrp(0,0)> is portable. See also
C<POSIX​::setsid()>.

+Portability issues​: L<perlport/setpgrp>.
+
=item setpriority WHICH,WHO,PRIORITY
X<setpriority> X<priority> X<nice> X<renice>

@​@​ -5517,6 +5611,8 @​@​ Sets the current priority for a process, a process group, or a user.
(See setpriority(2).) Raises an exception when used on a machine
that doesn't implement setpriority(2).

+Portability issues​: L<perlport/setpriority>.
+
=item setsockopt SOCKET,LEVEL,OPTNAME,OPTVAL
X<setsockopt>

@​@​ -5531,6 +5627,8 @​@​ An example disabling Nagle's algorithm on a socket​:
  use Socket qw(IPPROTO_TCP TCP_NODELAY);
  setsockopt($socket, IPPROTO_TCP, TCP_NODELAY, 1);

+Portability issues​: L<perlport/setsockopt>.
+
=item shift ARRAY
X<shift>

@​@​ -5568,6 +5666,8 @​@​ structure. Returns like ioctl​: C<undef> for error; "C<0> but
true" for zero; and the actual return value otherwise.
See also L<perlipc/"SysV IPC"> and C<IPC​::SysV> documentation.

+Portability issues​: L<perlport/shmctl>.
+
=item shmget KEY,SIZE,FLAGS
X<shmget>

@​@​ -5575,6 +5675,8 @​@​ Calls the System V IPC function shmget. Returns the shared memory
segment id, or C<undef> on error.
See also L<perlipc/"SysV IPC"> and C<IPC​::SysV> documentation.

+Portability issues​: L<perlport/shmget>.
+
=item shmread ID,VAR,POS,SIZE
X<shmread>
X<shmwrite>
@​@​ -5590,6 +5692,8 @​@​ SIZE bytes. Return true if successful, false on error.
shmread() taints the variable. See also L<perlipc/"SysV IPC">,
C<IPC​::SysV>, and the C<IPC​::Shareable> module from CPAN.

+Portability issues​: L<perlport/shmread> and L<perlport/shmwrite>.
+
=item shutdown SOCKET,HOW
X<shutdown>

@​@​ -5694,6 +5798,8 @​@​ See L<perlipc> for an example of socketpair use. Perl 5.8 and later will
emulate socketpair using IP sockets to localhost if your system implements
sockets but not socketpair.

+Portability issues​: L<perlport/socketpair>.
+
=item sort SUBNAME LIST
X<sort> X<qsort> X<quicksort> X<mergesort>

@​@​ -6602,6 +6708,8 @​@​ See your native chmod(2) and stat(2) documentation for more details
about the C<S_*> constants. To get status info for a symbolic link
instead of the target file behind the link, use the C<lstat> function.

+Portability issues​: L<perlport/stat>.
+
=item state EXPR
X<state>

@​@​ -6771,6 +6879,8 @​@​ use eval​:

  $symlink_exists = eval { symlink("",""); 1 };

+Portability issues​: L<perlport/symlink>.
+
=item syscall NUMBER, LIST
X<syscall> X<system call>

@​@​ -6806,6 +6916,8 @​@​ number of the read end of the pipe it creates, but there is no way
to retrieve the file number of the other end. You can avoid this
problem by using C<pipe> instead.

+Portability issues​: L<perlport/syscall>.
+
=item sysopen FILEHANDLE,FILENAME,MODE
X<sysopen>

@​@​ -6869,6 +6981,8 @​@​ library, or perhaps using the POSIX​::open() function.

See L<perlopentut> for a kinder, gentler explanation of opening files.

+Portability issues​: L<perlport/sysopen>.
+
=item sysread FILEHANDLE,SCALAR,LENGTH,OFFSET
X<sysread>

@​@​ -7004,6 +7118,8 @​@​ See L<perlop/"`STRING`"> and L</exec> for details.
Since C<system> does a C<fork> and C<wait> it may affect a C<SIGCHLD>
handler. See L<perlipc> for details.

+Portability issues​: L<perlport/system>.
+
=item syswrite FILEHANDLE,SCALAR,LENGTH,OFFSET
X<syswrite>

@​@​ -7198,6 +7314,8 @​@​ In scalar context, C<times> returns C<$user>.

Children's times are only included for terminated children.

+Portability issues​: L<perlport/times>.
+
=item tr///

The transliteration operator. Same as C<y///>. See
@​@​ -7218,6 +7336,8 @​@​ file.
The position in the file of FILEHANDLE is left unchanged. You may want to
call L<seek|/"seek FILEHANDLE,POSITION,WHENCE"> before writing to the file.

+Portability issues​: L<perlport/truncate>.
+
=item uc EXPR
X<uc> X<uppercase> X<toupper>

@​@​ -7285,6 +7405,8 @​@​ not trying to restrict access for yourself, returns C<undef>.
Remember that a umask is a number, usually given in octal; it is I<not> a
string of octal digits. See also L</oct>, if all you have is a string.

+Portability issues​: L<perlport/umask>.
+
=item undef EXPR
X<undef> X<undefine>

@​@​ -7595,6 +7717,8 @​@​ files. On systems that don't support futimes(2), passing filehandles raises
an exception. Filehandles must be passed as globs or glob references to be
recognized; barewords are considered filenames.

+Portability issues​: L<perlport/utime>.
+
=item values HASH
X<values>

@​@​ -7888,6 +8012,8 @​@​ being automatically reaped, as described in L<perlipc>.
If you use wait in your handler for $SIG{CHLD} it may accidentally for the
child created by qx() or system(). See L<perlipc> for details.

+Portability issues​: L<perlport/wait>.
+
=item waitpid PID,FLAGS
X<waitpid>

@​@​ -7913,6 +8039,8 @​@​ Note that on some systems, a return value of C<-1> could mean that child
processes are being automatically reaped. See L<perlipc> for details,
and for other examples.

+Portability issues​: L<perlport/waitpid>.
+
=item wantarray
X<wantarray> X<context>

--
1.7.3.1.msysgit.0

@p5pRT
Copy link
Author

p5pRT commented May 24, 2011

From Bo.Johansson@lsn.se

(Same message but patch moved to file)

To write portable Perl code there are many things to consider.
Portability issues are dealt with in separate documents or sections
and this make programmers working on the reference platform
(Unix/Linux) less aware of problems in other platforms.

This patch​:

1) Adds information about portability issues in the
"Alphabetical Listing of Perl Functions" in perlfunc.pod.

2) In perlfork.pod adds a section about kill on forked
processes in portable Perl code.

@p5pRT
Copy link
Author

p5pRT commented May 24, 2011

From Bo.Johansson@lsn.se

0001-Improve-documentation-to-support-portability.patch
From be5ca44137a6934c3360c55b259706be328e368e Mon Sep 17 00:00:00 2001
From: bojilund <bo.johansso@lsn.se>
Date: Tue, 24 May 2011 15:27:44 +0200
Subject: [PATCH] Improve documentation to support portability

---
 pod/perlfork.pod |   12 +++++
 pod/perlfunc.pod |  134 ++++++++++++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 143 insertions(+), 3 deletions(-)

diff --git a/pod/perlfork.pod b/pod/perlfork.pod
index 709d053..4eeab97 100644
--- a/pod/perlfork.pod
+++ b/pod/perlfork.pod
@@ -307,6 +307,18 @@ are expected to be fixed for thread-safety.
 
 =back
 
+=head1 PORTABLE PERL CODE AND KILL OF FORKED PROCESSES
+
+In portable Perl code, kill(9, $child) must not be used on forked processes.
+
+Forked process are in Windows implemented as a pseudo-processes.
+To use kill(9, $child) on pseudo-processes is unsafe.
+The process which implements the pseudo-processes can be blocked and the Perl interpreter hangs.
+
+The outcome of kill on a pseudo-process is unpredictable.
+It depends on the timing in the Windows operating system.
+Code that has worked, suddenly can fail, resulting in errors which are difficult to find.
+
 =head1 BUGS
 
 =over 8
diff --git a/pod/perlfunc.pod b/pod/perlfunc.pod
index 91a19a2..91ab03e 100644
--- a/pod/perlfunc.pod
+++ b/pod/perlfunc.pod
@@ -430,6 +430,8 @@ C<-x $file && -w _ && -f _>. (This is only fancy fancy: if you use
 the return value of C<-f $file> as an argument to another filetest
 operator, no special magic will happen.)
 
+Portability issues: L<perlport/x>.
+
 =item abs VALUE
 X<abs> X<absolute>
 
@@ -500,6 +502,8 @@ modulo the caveats given in L<perlipc/"Signals">.
 
 For more information see L<perlipc>.
 
+Portability issues: L<perlport/alarm>.
+
 =item atan2 Y,X
 X<atan2> X<arctangent> X<tan> X<tangent>
 
@@ -513,6 +517,8 @@ function, or use the familiar relation:
 The return value for C<atan2(0,0)> is implementation-defined; consult
 your atan2(3) manpage for more information.
 
+Portability issues: L<perlport/atan2>.
+
 =item bind SOCKET,NAME
 X<bind>
 
@@ -612,6 +618,8 @@ but also when using read(), seek(), sysread(), syswrite() and tell()
 in L<perlvar> for how to manually set your input and output
 line-termination sequences.
 
+Portability issues: L<perlport/binmode>.
+
 =item bless REF,CLASSNAME
 X<bless>
 
@@ -761,6 +769,8 @@ module:
     chmod S_IRWXU|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH, @executables;
     # Identical to the chmod 0755 of the example above.
 
+Portability issues: L<perlport/chmod>.
+
 =item chomp VARIABLE
 X<chomp> X<INPUT_RECORD_SEPARATOR> X<$/> X<newline> X<eol>
 
@@ -864,6 +874,8 @@ On POSIX systems, you can detect this condition this way:
     use POSIX qw(sysconf _PC_CHOWN_RESTRICTED);
     $can_chown_giveaway = not sysconf(_PC_CHOWN_RESTRICTED);
 
+Portability issues: L<perlport/chmod>.
+
 =item chr NUMBER
 X<chr> X<character> X<ASCII> X<Unicode>
 
@@ -898,6 +910,8 @@ change your current working directory, which is unaffected.)  For security
 reasons, this call is restricted to the superuser.  If FILENAME is
 omitted, does a C<chroot> to C<$_>.
 
+Portability issues: L<perlport/chroot>.
+
 =item close FILEHANDLE
 X<close>
 
@@ -1089,6 +1103,8 @@ the string back to an eight-bit byte string before calling crypt()
 (on that copy).  If that works, good.  If not, crypt() dies with
 C<Wide character in crypt>.
 
+Portability issues: L<perlport/crypt>.
+
 =item dbmclose HASH
 X<dbmclose>
 
@@ -1096,6 +1112,8 @@ X<dbmclose>
 
 Breaks the binding between a DBM file and a hash.
 
+Portability issues: L<perlport/dbmclose>.
+
 =item dbmopen HASH,DBNAME,MASK
 X<dbmopen> X<dbm> X<ndbm> X<sdbm> X<gdbm>
 
@@ -1139,6 +1157,8 @@ before you call dbmopen():
     dbmopen(%NS_Hist, "$ENV{HOME}/.netscape/history.db")
         or die "Can't open netscape history file: $!";
 
+Portability issues: L<perlport/dbmopen>.
+
 =item default BLOCK
 
 Within a C<foreach> or a C<given>, a C<default> BLOCK acts like a C<when>
@@ -1475,6 +1495,8 @@ convert a core file into an executable. That's why you should now invoke
 it as C<CORE::dump()>, if you don't want to be warned against a possible
 typo.
 
+Portability issues: L<perlport/dump>.
+
 =item each HASH
 X<each> X<hash, iterator>
 
@@ -1802,6 +1824,8 @@ open handles to avoid lost output.
 Note that C<exec> will not call your C<END> blocks, nor will it invoke
 C<DESTROY> methods on your objects.
 
+Portability issues: L<perlport/exec>.
+
 =item exists EXPR
 X<exists> X<autovivification>
 
@@ -1896,6 +1920,8 @@ can change the exit status by modifying C<$?>. If this is a problem, you
 can call C<POSIX:_exit($status)> to avoid END and destructor processing.
 See L<perlmod> for details.
 
+Portability issues: L<perlport/exit>.
+
 =item exp EXPR
 X<exp> X<exponential> X<antilog> X<antilogarithm> X<e>
 
@@ -1941,6 +1967,8 @@ on your own, though.
     $flags = fcntl(REMOTE, F_SETFL, $flags | O_NONBLOCK)
                 or die "Can't set flags for the socket: $!\n";
 
+Portability issues: L<perlport/fcntl>.
+
 =item fileno FILEHANDLE
 X<fileno>
 
@@ -2041,6 +2069,8 @@ function lose their locks, making it seriously harder to write servers.
 
 See also L<DB_File> for other flock() examples.
 
+Portability issues: L<perlport/flock>.
+
 =item fork
 X<fork> X<child> X<parent>
 
@@ -2070,6 +2100,14 @@ if you exit, then the remote server (such as, say, a CGI script or a
 backgrounded job launched from a remote shell) won't think you're done.
 You should reopen those to F</dev/null> if it's any issue.
 
+On some platforms such as Windows, where the fork() system call is not available,
+Perl can be built to emulate fork() in the Perl interpreter. The emulation is designed to,
+at the level of the Perl program, be as compatible as possible with the "Unix" fork().
+However it has limitation that has to be considered in code intended to be portable.
+See L<perlfork> for more details.
+
+Portability issues: L<perlport/fork>.
+
 =item format
 X<format>
 
@@ -2161,6 +2199,8 @@ returns the empty string, use C<getpwuid>.
 Do not consider C<getlogin> for authentication: it is not as
 secure as C<getpwuid>.
 
+Portability issues: L<perlport/getlogin>.
+
 =item getpeername SOCKET
 X<getpeername> X<peer>
 
@@ -2183,6 +2223,8 @@ doesn't implement getpgrp(2).  If PID is omitted, returns the process
 group of the current process.  Note that the POSIX version of C<getpgrp>
 does not accept a PID argument, so only C<PID==0> is truly portable.
 
+Portability issues: L<perlport/getpgrp>.
+
 =item getppid
 X<getppid> X<parent> X<pid>
 
@@ -2195,6 +2237,8 @@ C<getppid()>, that returns a consistent value across threads. If you want
 to call the underlying C<getppid()>, you may use the CPAN module
 C<Linux::Pid>.
 
+Portability issues: L<perlport/getppid>.
+
 =item getpriority WHICH,WHO
 X<getpriority> X<priority> X<nice>
 
@@ -2202,6 +2246,8 @@ Returns the current priority for a process, a process group, or a user.
 (See C<getpriority(2)>.)  Will raise a fatal exception if used on a
 machine that doesn't implement getpriority(2).
 
+Portability issues: L<perlport/getpriority>.
+
 =item getpwnam NAME
 X<getpwnam> X<getgrnam> X<gethostbyname> X<getnetbyname> X<getprotobyname>
 X<getpwuid> X<getgrgid> X<getservbyname> X<gethostbyaddr> X<getnetbyaddr>
@@ -2373,6 +2419,8 @@ Even though it looks as though they're the same method calls (uid),
 they aren't, because a C<File::stat> object is different from
 a C<User::pwent> object.
 
+Portability issues: L<perlport/getpwnam> to L<perlport/endservent>.
+
 =item getsockname SOCKET
 X<getsockname>
 
@@ -2418,6 +2466,7 @@ Here's an example to test whether Nagle's algorithm is enabled on a socket:
     my $nodelay = unpack("I", $packed);
     print "Nagle's algorithm is turned ", $nodelay ? "off\n" : "on\n";
 
+Portability issues: L<perlport/getsockopt>.
 
 =item given EXPR BLOCK
 X<given>
@@ -2472,6 +2521,8 @@ Beginning with v5.6.0, this operator is implemented using the standard
 C<File::Glob> extension.  See L<File::Glob> for details, including
 C<bsd_glob> which does not treat whitespace as a pattern separator.
 
+Portability issues: L<perlport/glob>.
+
 =item gmtime EXPR
 X<gmtime> X<UTC> X<Greenwich>
 
@@ -2484,7 +2535,7 @@ Note: When called in list context, $isdst, the last value
 returned by gmtime, is always C<0>.  There is no
 Daylight Saving Time in GMT.
 
-See L<perlport/gmtime> for portability concerns.
+Portability issues: L<perlport/gmtime>.
 
 =item goto LABEL
 X<goto> X<jump> X<jmp>
@@ -2661,6 +2712,8 @@ system:
 The special string C<"0 but true"> is exempt from B<-w> complaints
 about improper numeric conversions.
 
+Portability issues: L<perlport/ioctl>.
+
 =item join EXPR,LIST
 X<join>
 
@@ -2771,6 +2824,15 @@ signal the current process group and -1 will signal all processes.
 
 See L<perlipc/"Signals"> for more details.
 
+On some platforms such as Windows where the fork() system call is not available.
+Perl can be built to emulate fork() at the interpreter level.
+This emulation has limitation related to kill that has to be considered,
+for code running on Windows and in code intended to be portable.
+
+See L<perlfork> for more details.
+
+Portability issues: L<perlport/kill>.
+
 =item last LABEL
 X<last> X<break>
 
@@ -2897,6 +2959,8 @@ X<link>
 Creates a new filename linked to the old filename.  Returns true for
 success, false otherwise.
 
+Portability issues: L<perlport/link>.
+
 =item listen SOCKET,QUEUESIZE
 X<listen>
 
@@ -2990,8 +3054,6 @@ try for example:
 Note that the C<%a> and C<%b>, the short forms of the day of the week
 and the month of the year, may not necessarily be three characters wide.
 
-See L<perlport/localtime> for portability concerns.
-
 The L<Time::gmtime> and L<Time::localtime> modules provide a convenient,
 by-name access mechanism to the gmtime() and localtime() functions,
 respectively.
@@ -2999,6 +3061,8 @@ respectively.
 For a comprehensive date and time representation look at the
 L<DateTime> module on CPAN.
 
+Portability issues: L<perlport/localtime>.
+
 =item lock THING
 X<lock>
 
@@ -3041,6 +3105,8 @@ information, please see the documentation for C<stat>.
 
 If EXPR is omitted, stats C<$_>.
 
+Portability issues: L<perlport/lstat>.
+
 =item m//
 
 The match operator.  See L<perlop/"Regexp Quote-Like Operators">.
@@ -3165,6 +3231,8 @@ C<"0 but true"> for zero, or the actual return value otherwise.  See also
 L<perlipc/"SysV IPC"> and the documentation for C<IPC::SysV> and
 C<IPC::Semaphore>.
 
+Portability issues: L<perlport/msgctl>.
+
 =item msgget KEY,FLAGS
 X<msgget>
 
@@ -3173,6 +3241,8 @@ id, or C<undef> on error.  See also
 L<perlipc/"SysV IPC"> and the documentation for C<IPC::SysV> and
 C<IPC::Msg>.
 
+Portability issues: L<perlport/msgget>.
+
 =item msgrcv ID,VAR,SIZE,TYPE,FLAGS
 X<msgrcv>
 
@@ -3185,6 +3255,8 @@ Taints the variable.  Returns true if successful, false
 on error.  See also L<perlipc/"SysV IPC"> and the documentation for
 C<IPC::SysV> and C<IPC::SysV::Msg>.
 
+Portability issues: L<perlport/msgrcv>.
+
 =item msgsnd ID,MSG,FLAGS
 X<msgsnd>
 
@@ -3196,6 +3268,8 @@ C<pack("l! a*", $type, $message)>.  Returns true if successful,
 false on error.  See also the C<IPC::SysV>
 and C<IPC::SysV::Msg> documentation.
 
+Portability issues: L<perlport/msgsnd>.
+
 =item my EXPR
 X<my>
 
@@ -3705,6 +3779,8 @@ yourself and inspect the return value.
 
 See L</seek> for some details about mixing reading and writing.
 
+Portability issues: L<perlport/open>.
+
 =item opendir DIRHANDLE,EXPR
 X<opendir>
 
@@ -4823,6 +4899,8 @@ implemented.  If not, raises an exception.  If there is a system
 error, returns the undefined value and sets C<$!> (errno).  If EXPR is
 omitted, uses C<$_>.
 
+Portability issues: L<perlport/readlink>.
+
 =item readpipe EXPR
 
 =item readpipe
@@ -4956,6 +5034,8 @@ rename(2) manpage or equivalent system documentation for details.
 For a platform independent C<move> function look at the L<File::Copy>
 module.
 
+Portability issues: L<perlport/rename>.
+
 =item require VERSION
 X<require>
 
@@ -5216,6 +5296,8 @@ X<rewinddir>
 Sets the current position to the beginning of the directory for the
 C<readdir> routine on DIRHANDLE.
 
+Portability issues: L<perlport/rewinddir>.
+
 =item rindex STR,SUBSTR,POSITION
 X<rindex>
 
@@ -5374,6 +5456,8 @@ methods, preferring to write the last example as:
     use IO::Handle;
     STDERR->autoflush(1);
 
+Portability issues: L<perlport/select>.
+
 =item select RBITS,WBITS,EBITS,TIMEOUT
 X<select>
 
@@ -5438,6 +5522,8 @@ B<WARNING>: One should not attempt to mix buffered I/O (like C<read>
 or <FH>) with C<select>, except as permitted by POSIX, and even
 then only on POSIX systems.  You have to use C<sysread> instead.
 
+Portability issues: L<perlport/select>.
+
 =item semctl ID,SEMNUM,CMD,ARG
 X<semctl>
 
@@ -5454,6 +5540,8 @@ short integers, which may be created with C<pack("s!",(0)x$nsem)>.
 See also L<perlipc/"SysV IPC">, C<IPC::SysV>, C<IPC::Semaphore>
 documentation.
 
+Portability issues: L<perlport/semctl>.
+
 =item semget KEY,NSEMS,FLAGS
 X<semget>
 
@@ -5462,6 +5550,8 @@ the undefined value on error.  See also
 L<perlipc/"SysV IPC">, C<IPC::SysV>, C<IPC::SysV::Semaphore>
 documentation.
 
+Portability issues: L<perlport/semget>.
+
 =item semop KEY,OPSTRING
 X<semop>
 
@@ -5480,6 +5570,8 @@ To signal the semaphore, replace C<-1> with C<1>.  See also
 L<perlipc/"SysV IPC">, C<IPC::SysV>, and C<IPC::SysV::Semaphore>
 documentation.
 
+Portability issues: L<perlport/semop>.
+
 =item send SOCKET,MSG,FLAGS,TO
 X<send>
 
@@ -5510,6 +5602,8 @@ it defaults to C<0,0>.  Note that the BSD 4.2 version of C<setpgrp> does not
 accept any arguments, so only C<setpgrp(0,0)> is portable.  See also
 C<POSIX::setsid()>.
 
+Portability issues: L<perlport/setpgrp>.
+
 =item setpriority WHICH,WHO,PRIORITY
 X<setpriority> X<priority> X<nice> X<renice>
 
@@ -5517,6 +5611,8 @@ Sets the current priority for a process, a process group, or a user.
 (See setpriority(2).)  Raises an exception when used on a machine
 that doesn't implement setpriority(2).
 
+Portability issues: L<perlport/setpriority>.
+
 =item setsockopt SOCKET,LEVEL,OPTNAME,OPTVAL
 X<setsockopt>
 
@@ -5531,6 +5627,8 @@ An example disabling Nagle's algorithm on a socket:
     use Socket qw(IPPROTO_TCP TCP_NODELAY);
     setsockopt($socket, IPPROTO_TCP, TCP_NODELAY, 1);
 
+Portability issues: L<perlport/setsockopt>.
+
 =item shift ARRAY
 X<shift>
 
@@ -5568,6 +5666,8 @@ structure.  Returns like ioctl: C<undef> for error; "C<0> but
 true" for zero; and the actual return value otherwise.
 See also L<perlipc/"SysV IPC"> and C<IPC::SysV> documentation.
 
+Portability issues: L<perlport/shmctl>.
+
 =item shmget KEY,SIZE,FLAGS
 X<shmget>
 
@@ -5575,6 +5675,8 @@ Calls the System V IPC function shmget.  Returns the shared memory
 segment id, or C<undef> on error.
 See also L<perlipc/"SysV IPC"> and C<IPC::SysV> documentation.
 
+Portability issues: L<perlport/shmget>.
+
 =item shmread ID,VAR,POS,SIZE
 X<shmread>
 X<shmwrite>
@@ -5590,6 +5692,8 @@ SIZE bytes.  Return true if successful, false on error.
 shmread() taints the variable. See also L<perlipc/"SysV IPC">,
 C<IPC::SysV>, and the C<IPC::Shareable> module from CPAN.
 
+Portability issues: L<perlport/shmread> and L<perlport/shmwrite>.
+
 =item shutdown SOCKET,HOW
 X<shutdown>
 
@@ -5694,6 +5798,8 @@ See L<perlipc> for an example of socketpair use.  Perl 5.8 and later will
 emulate socketpair using IP sockets to localhost if your system implements
 sockets but not socketpair.
 
+Portability issues: L<perlport/socketpair>.
+
 =item sort SUBNAME LIST
 X<sort> X<qsort> X<quicksort> X<mergesort>
 
@@ -6602,6 +6708,8 @@ See your native chmod(2) and stat(2) documentation for more details
 about the C<S_*> constants.  To get status info for a symbolic link
 instead of the target file behind the link, use the C<lstat> function.
 
+Portability issues: L<perlport/stat>.
+
 =item state EXPR
 X<state>
 
@@ -6771,6 +6879,8 @@ use eval:
 
     $symlink_exists = eval { symlink("",""); 1 };
 
+Portability issues: L<perlport/symlink>.
+
 =item syscall NUMBER, LIST
 X<syscall> X<system call>
 
@@ -6806,6 +6916,8 @@ number of the read end of the pipe it creates, but there is no way
 to retrieve the file number of the other end.  You can avoid this
 problem by using C<pipe> instead.
 
+Portability issues: L<perlport/syscall>.
+
 =item sysopen FILEHANDLE,FILENAME,MODE
 X<sysopen>
 
@@ -6869,6 +6981,8 @@ library, or perhaps using the POSIX::open() function.
 
 See L<perlopentut> for a kinder, gentler explanation of opening files.
 
+Portability issues: L<perlport/sysopen>.
+
 =item sysread FILEHANDLE,SCALAR,LENGTH,OFFSET
 X<sysread>
 
@@ -7004,6 +7118,8 @@ See L<perlop/"`STRING`"> and L</exec> for details.
 Since C<system> does a C<fork> and C<wait> it may affect a C<SIGCHLD>
 handler. See L<perlipc> for details.
 
+Portability issues: L<perlport/system>.
+
 =item syswrite FILEHANDLE,SCALAR,LENGTH,OFFSET
 X<syswrite>
 
@@ -7198,6 +7314,8 @@ In scalar context, C<times> returns C<$user>.
 
 Children's times are only included for terminated children.
 
+Portability issues: L<perlport/times>.
+
 =item tr///
 
 The transliteration operator.  Same as C<y///>.  See
@@ -7218,6 +7336,8 @@ file.
 The position in the file of FILEHANDLE is left unchanged.  You may want to
 call L<seek|/"seek FILEHANDLE,POSITION,WHENCE"> before writing to the file.
 
+Portability issues: L<perlport/truncate>.
+
 =item uc EXPR
 X<uc> X<uppercase> X<toupper>
 
@@ -7285,6 +7405,8 @@ not trying to restrict access for yourself, returns C<undef>.
 Remember that a umask is a number, usually given in octal; it is I<not> a
 string of octal digits.  See also L</oct>, if all you have is a string.
 
+Portability issues: L<perlport/umask>.
+
 =item undef EXPR
 X<undef> X<undefine>
 
@@ -7595,6 +7717,8 @@ files.  On systems that don't support futimes(2), passing filehandles raises
 an exception.  Filehandles must be passed as globs or glob references to be
 recognized; barewords are considered filenames.
 
+Portability issues: L<perlport/utime>.
+
 =item values HASH
 X<values>
 
@@ -7888,6 +8012,8 @@ being automatically reaped, as described in L<perlipc>.
 If you use wait in your handler for $SIG{CHLD} it may accidentally for the
 child created by qx() or system(). See L<perlipc> for details.
 
+Portability issues: L<perlport/wait>.
+
 =item waitpid PID,FLAGS
 X<waitpid>
 
@@ -7913,6 +8039,8 @@ Note that on some systems, a return value of C<-1> could mean that child
 processes are being automatically reaped.  See L<perlipc> for details,
 and for other examples.
 
+Portability issues: L<perlport/waitpid>.
+
 =item wantarray
 X<wantarray> X<context>
 
-- 
1.7.3.1.msysgit.0

@p5pRT
Copy link
Author

p5pRT commented May 24, 2011

Bo.Johansson@lsn.se - Status changed from 'new' to 'open'

@p5pRT
Copy link
Author

p5pRT commented May 25, 2011

Bo.Johansson@lsn.se - Status changed from 'open' to 'new'

@p5pRT
Copy link
Author

p5pRT commented May 29, 2011

From @cpansprout

On Tue May 24 07​:06​:14 2011, boilund wrote​:

From be5ca44137a6934c3360c55b259706be328e368e Mon Sep 17 00​:00​:00 2001
From​: bojilund <bo.johansso@​lsn.se>
Date​: Tue, 24 May 2011 15​:27​:44 +0200

To write portable Perl code there are many things to consider.
Portability issues are dealt with in separate documents or sections
and this make programmers working on the reference platform
(Unix/Linux) less aware of problems in other platforms.

This patch​:

1) Adds information about portability issues in the
"Alphabetical Listing of Perl Functions" in perlfunc.pod.

I’m not sure it’s a good idea to add the reference to every entry in
perlfunc. It tends to add clutter. Also, awareness of portability issues
can never replace testing, and those who test their code on multiple
platforms will very quickly become aware of portability issues anyway.

2) In perlfork.pod adds a section about kill on forked
processes in portable Perl code.

---
pod/perlfork.pod | 12 +++++
pod/perlfunc.pod | 134
++++++++++++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 143 insertions(+), 3 deletions(-)

diff --git a/pod/perlfork.pod b/pod/perlfork.pod
index 709d053..4eeab97 100644
--- a/pod/perlfork.pod
+++ b/pod/perlfork.pod
@​@​ -307,6 +307,18 @​@​ are expected to be fixed for thread-safety.

=back

+=head1 PORTABLE PERL CODE AND KILL OF FORKED PROCESSES
+
+In portable Perl code, kill(9, $child) must not be used on forked
processes.
+
+Forked process are in Windows implemented as a pseudo-processes.
+To use kill(9, $child) on pseudo-processes is unsafe.
+The process which implements the pseudo-processes can be blocked and
the Perl interpreter hangs.
+
+The outcome of kill on a pseudo-process is unpredictable.
+It depends on the timing in the Windows operating system.
+Code that has worked, suddenly can fail, resulting in errors which
are difficult to find.
+

perlfork already has this entry​:

=item kill()

C<kill('KILL', ...)> can be used to terminate a pseudo-process by
passing it the ID returned by fork(). This should not be used except
under dire circumstances, because the operating system may not
guarantee integrity of the process resources when a running thread is
terminated. Note that using C<kill('KILL', ...)> on a
pseudo-process() may typically cause memory leaks, because the thread
that implements the pseudo-process does not get a chance to clean up
its resources.

C<kill('TERM', ...)> can also be used on pseudo-processes, but the
signal will not be delivered while the pseudo-process is blocked by a
system call, e.g. waiting for a socket to connect, or trying to read
from a socket with no data available. Starting in Perl 5.14 the
parent process will not wait for children to exit once they have been
signalled with C<kill('TERM', ...)> to avoid deadlock during process
exit. You will have to explicitly call waitpid() to make sure the
child has time to clean-up itself, but you are then also responsible
that the child is not blocking on I/O either.

Does that not already cover this topic?

@p5pRT
Copy link
Author

p5pRT commented May 29, 2011

The RT System itself - Status changed from 'new' to 'open'

@p5pRT
Copy link
Author

p5pRT commented May 31, 2011

@cpansprout - Status changed from 'open' to 'rejected'

@p5pRT
Copy link
Author

p5pRT commented May 31, 2011

From Bo.Johansson@lsn.se

Father Chrysostomos, thank you for answering!

First some BACKGROUND to the proposed patch.

I have used Perl for more than 20 years, but I am quit new to installing
from CPAN using the cpan-utility.
As a test I wanted to create local HTTP-server written in Perl.
This small work resulted in the following bug reports​:

Module Test-TCP​:
  https://rt.cpan.org/Public/Bug/Display.html?id=66437 and
  https://rt.cpan.org/Public/Bug/Display.html?id=67292.
  Input was also given to
https://rt.cpan.org/Public/Bug/Display.html?id=66016.

Module HTTP-Server-Simple​:
  https://rt.cpan.org/Public/Bug/Display.html?id=67249

Module Plack​:
  https://rt.cpan.org/Public/Bug/Display.html?id=67051

Perl function listen to socket​:
  http​://rt.perl.org/rt3//Public/Bug/Display.html?id=88080

(The result of the bug reports are not overwhelming. Portability of test do
not seem to be a focused area)

One of my conclusions was that Perl does not provide enough support for
writing portable Perl code.

I wrote the PerlMonks meditation​: "Proposal how to make modules using fork
more portable"
http​://www.perlmonks.org/?node_id=896360.
One of the main starting point for this patch is that moritz wrote in a
reply​:
"I'm all for better documentation, and in my experience,
p5p has been very responsive to small scale doc patches."

-----Original Message-----
From​: Father Chrysostomos via RT
Sent​: Sunday, May 29, 2011 10​:35 PM

On Tue May 24 07​:06​:14 2011, boilund wrote​:

From be5ca44137a6934c3360c55b259706be328e368e Mon Sep 17 00​:00​:00 2001
From​: bojilund <bo.johansso@​lsn.se>
Date​: Tue, 24 May 2011 15​:27​:44 +0200

To write portable Perl code there are many things to consider.
Portability issues are dealt with in separate documents or sections
and this make programmers working on the reference platform
(Unix/Linux) less aware of problems in other platforms.

This patch​:

1) Adds information about portability issues in the
"Alphabetical Listing of Perl Functions" in perlfunc.pod.

I´m not sure it´s a good idea to add the reference to every entry in
perlfunc. It tends to add clutter. Also, awareness of portability issues
can never replace testing, and those who test their code on multiple
platforms will very quickly become aware of portability issues anyway.

I am quit sure that the "small cost" to add some "cluttering"
will pay off as improved portability of Perl code.
When selecting a function to use you should be aware of portability issues
for the functions.

(What I also want is some sort of mark in the headline of functions with
portability issues.
Example​: kill SIGNAL, LIST *not portable*.)

Non portable tests used in the test of modules are a problem.
Tests can not be run on all platforms and portability issues are not
detected.
It is difficult to install modules using Strawbery Perl and the cpan
utility,
because the tests fails and the install fails.

I have also found a type of portability problems which are difficult to find
using normal testing.
See below form more information.

2) In perlfork.pod adds a section about kill on forked
processes in portable Perl code.

---
pod/perlfork.pod | 12 +++++
pod/perlfunc.pod | 134
++++++++++++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 143 insertions(+), 3 deletions(-)

diff --git a/pod/perlfork.pod b/pod/perlfork.pod
index 709d053..4eeab97 100644
--- a/pod/perlfork.pod
+++ b/pod/perlfork.pod
@​@​ -307,6 +307,18 @​@​ are expected to be fixed for thread-safety.

=back

+=head1 PORTABLE PERL CODE AND KILL OF FORKED PROCESSES
+
+In portable Perl code, kill(9, $child) must not be used on forked
processes.
+
+Forked process are in Windows implemented as a pseudo-processes.
+To use kill(9, $child) on pseudo-processes is unsafe.
+The process which implements the pseudo-processes can be blocked and
the Perl interpreter hangs.
+
+The outcome of kill on a pseudo-process is unpredictable.
+It depends on the timing in the Windows operating system.
+Code that has worked, suddenly can fail, resulting in errors which
are difficult to find.
+

perlfork already has this entry​:

=item kill()

C<kill('KILL', ...)> can be used to terminate a pseudo-process by
passing it the ID returned by fork(). This should not be used except
under dire circumstances, because the operating system may not
guarantee integrity of the process resources when a running thread is
terminated. Note that using C<kill('KILL', ...)> on a
pseudo-process() may typically cause memory leaks, because the thread
that implements the pseudo-process does not get a chance to clean up
its resources.

C<kill('TERM', ...)> can also be used on pseudo-processes, but the
signal will not be delivered while the pseudo-process is blocked by a
system call, e.g. waiting for a socket to connect, or trying to read
from a socket with no data available. Starting in Perl 5.14 the
parent process will not wait for children to exit once they have been
signalled with C<kill('TERM', ...)> to avoid deadlock during process
exit. You will have to explicitly call waitpid() to make sure the
child has time to clean-up itself, but you are then also responsible
that the child is not blocking on I/O either.

Does that not already cover this topic?

I have used Perl in many years and have not observed the "item kill()".
Even if I had observed it I had probably not understood the consequences.
I strongly believes that many more also do not understand the consequences
of
using kill on a forked process in Windows and other non Unix/Linux operating
systems.

Concrete rules and recommendations what to do is needed.

Some reasons why it is important to highlight the portability issues with
kill are​:

- Kill are frequently used in Perl code.
- One common cause making tests none portable is the use of kill on forked
processes.
- Module test can result in "false fails" because of kill on forked
processes.
- It is difficult to install modules using (Windows, Strawbery Perl and) the
cpan utility.
- The result of kill on forked processes is unpredictable.
  See bellow "UNPREDICTABLE RESULT OF KILL ON PSEUDO-PROCESS".
- The portability problem with Kill can be missed in tests, because of the
unpredictability.

UNPREDICTABLE RESULT OF KILL ON PSEUDO-PROCESS

Observations​:

1) This always blocks in Windows 7, but not on Windows 2000​:
perl -e "if ($pid=fork){kill(9, $pid);} else {sleep 1000 }"

2) This sometimes blocks and sometimes gives the wrong exit value 9 in
Windows 7​:
perl -e "if ($pid=fork){Win32​::Sleep(0); kill(9, $pid);} else {sleep 1000}"

3) Running this batch file a number of times on Windows 7​:

  @​echo off
  set count=0
  :loop
  set /a count=%count%+1
  echo Count %count%
  @​echo on
  perl -e "if ($pid=fork){Win32​::Sleep(0); kill(9, $pid); Win32​::Sleep(0)}
else {sleep 1000}"
  if errorlevel 1 goto exit
  @​echo off
  goto loop
  :exit
  ECHO.%ERRORLEVEL%

  gave the results​:

  Perl is blocked after between 30 to several thousand loops.
  Sometimes perl exits with the wrong exit value 9.
  One time using the same command window for more than 20 times,
  perl exited all the times after less the 10 loops with the wrong exit
value 9.
  Is there a missing initialization in the Perl (or Windows)
implementation?

4) The installations of module on Windows 7 using install in cpan frequently
hangs in the tests.

Conclusions and Implications​:
  - There seem to be a Perl portability problem between different versions
of Windows.
  - If a test uses kill on a pseudo-process, the test must be run many times
to detect the infrequent errors.
  - It is not enough to run a test one time.
  - There is problems to install modules using Windows 7 and Strawberry
Perl.
  - Cpan install blocks and the installation has to be restarted.

See also https://rt.cpan.org/Public/Bug/Display.html?id=66016#txn-910239.

Best regards

Bo Johansson

@p5pRT
Copy link
Author

p5pRT commented May 31, 2011

@cpansprout - Status changed from 'rejected' to 'open'

@p5pRT
Copy link
Author

p5pRT commented May 31, 2011

From @briandfoy

In article <rt-3.6.HEAD-16080-1306701350-570.91526-15-0@​perl.org>,
Father Chrysostomos via RT <perlbug-followup@​perl.org> wrote​:

1) Adds information about portability issues in the
"Alphabetical Listing of Perl Functions" in perlfunc.pod.

I�m not sure it�s a good idea to add the reference to every entry in
perlfunc. It tends to add clutter.

If something has a portability issue, we should mention it in the main
place people will read about the thing with the issue. For Perl
built-ins, that's perlfunc. We don't have to explain the issue, but we
should at the very least tell people where to find an explanation of
the issue.

@p5pRT
Copy link
Author

p5pRT commented May 31, 2011

From @khwilliamson

On 5/31/2011 1​:33 PM, brian d foy wrote​:

In article<rt-3.6.HEAD-16080-1306701350-570.91526-15-0@​perl.org>,
Father Chrysostomos via RT<perlbug-followup@​perl.org> wrote​:

1) Adds information about portability issues in the
"Alphabetical Listing of Perl Functions" in perlfunc.pod.

I’m not sure it’s a good idea to add the reference to every entry in
perlfunc. It tends to add clutter.

If something has a portability issue, we should mention it in the main
place people will read about the thing with the issue. For Perl
built-ins, that's perlfunc. We don't have to explain the issue, but we
should at the very least tell people where to find an explanation of
the issue.

+1

@p5pRT
Copy link
Author

p5pRT commented May 31, 2011

From @jandubois

On Tue, 31 May 2011, brian d foy wrote​:

I’m not sure it’s a good idea to add the reference to every entry in
perlfunc. It tends to add clutter.

If something has a portability issue, we should mention it in the main
place people will read about the thing with the issue. For Perl
built-ins, that's perlfunc. We don't have to explain the issue, but we
should at the very least tell people where to find an explanation of
the issue.

Are you suggesting to fold the whole list of "FUNCTION IMPLEMENTATIONS"
from perlport into perlfunc?

http​://search.cpan.org/~jesse/perl-5.14.0/pod/perlport.pod#FUNCTION_IMPLEMENTATIONS

Cheers,
-Jan

@p5pRT
Copy link
Author

p5pRT commented May 31, 2011

From Bo.Johansson@lsn.se

The proposal is (for functions with portability issues) to add a LINK
in the description of the function in
perlsub.html#Alphabetical-Listing-of-Perl-Functions
to the corresponding entry in perlport.html#FUNCTION-IMPLEMENTATIONS

-----Original Message-----
From​: Jan Dubois via RT
Sent​: Tuesday, May 31, 2011 10​:55 PM
To​: Bo.Johansson@​lsn.se
Subject​: RE​: [perl #91526] [PATCH] Improve documentation to support
portability

On Tue, 31 May 2011, brian d foy wrote​:

I’m not sure it’s a good idea to add the reference to every entry in
perlfunc. It tends to add clutter.

If something has a portability issue, we should mention it in the main
place people will read about the thing with the issue. For Perl
built-ins, that's perlfunc. We don't have to explain the issue, but we
should at the very least tell people where to find an explanation of
the issue.

Are you suggesting to fold the whole list of "FUNCTION IMPLEMENTATIONS"
from perlport into perlfunc?

http​://search.cpan.org/~jesse/perl-5.14.0/pod/perlport.pod#FUNCTION_IMPLEMENTATIONS

Cheers,
-Jan

@p5pRT
Copy link
Author

p5pRT commented Jun 6, 2011

From @cpansprout

On Mon May 30 19​:51​:51 2011, boilund wrote​:

Father Chrysostomos, thank you for answering!

I am quit sure that the "small cost" to add some "cluttering"
will pay off as improved portability of Perl code.
When selecting a function to use you should be aware of portability
issues
for the functions.

Fair enough. I tried applying your perlfunc patch, but it seems to have
been scrambled by your mail program (initial spaces before each
unmodified line have been stripped). Could you resend it as an attachment?

I have used Perl in many years and have not observed the "item
kill()".
Even if I had observed it I had probably not understood the
consequences.
I strongly believes that many more also do not understand the
consequences
of
using kill on a forked process in Windows and other non Unix/Linux
operating
systems.

Concrete rules and recommendations what to do is needed.

Some reasons why it is important to highlight the portability issues
with
kill are​:

...

I think it would be better to add something like this​:

=head1 PORTABILITY CAVEATS

Killing a pseudo-process may have unpredictable results. See
L</kill()>, above.

What do you think?

If the existing kill() entry is not sufficient, would you be willing to
expand on that, instead of creating a separate entry?

@p5pRT
Copy link
Author

p5pRT commented Jun 7, 2011

From Bo.Johansson@lsn.se

-----Original Message-----
From​: Father Chrysostomos via RT
Sent​: Monday, June 06, 2011 5​:38 AM
To​: Bo.Johansson@​lsn.se
Subject​: [perl #91526] [PATCH] Improve documentation to support portability

On Mon May 30 19​:51​:51 2011, boilund wrote​:

Father Chrysostomos, thank you for answering!

I am quit sure that the "small cost" to add some "cluttering"
will pay off as improved portability of Perl code.
When selecting a function to use you should be aware of portability
issues
for the functions.

Fair enough. I tried applying your perlfunc patch, but it seems to have
been scrambled by your mail program (initial spaces before each
unmodified line have been stripped). Could you resend it as an attachment?

Patch is attached as​:
0001-Improve-documentation-to-support-portability.patch

I have used Perl in many years and have not observed the "item
kill()".
Even if I had observed it I had probably not understood the
consequences.
I strongly believes that many more also do not understand the
consequences
of
using kill on a forked process in Windows and other non Unix/Linux
operating
systems.

Concrete rules and recommendations what to do is needed.

Some reasons why it is important to highlight the portability issues
with
kill are​:

...

I think it would be better to add something like this​:

=head1 PORTABILITY CAVEATS

Killing a pseudo-process may have unpredictable results. See
L</kill()>, above.

What do you think?

OK!

If the existing kill() entry is not sufficient, would you be willing to
expand on that, instead of creating a separate entry?

Proposal for changes to perlfork in the attached patch​:
0001-Add-information-about-portability-caveats-related-to.patch

@p5pRT
Copy link
Author

p5pRT commented Jun 7, 2011

From Bo.Johansson@lsn.se

0001-Improve-documentation-to-support-portability.patch
From 431c352c5f100131ab88c4e06acadbae490c115a Mon Sep 17 00:00:00 2001
From: bojilund <bo.johansso@lsn.se>
Date: Tue, 7 Jun 2011 09:32:31 +0200
Subject: [PATCH] Improve documentation to support portability

If something has a portability issue, we should mention it in the main
place people will read about the thing with the issue. For Perl
built-ins, that's perlfunc. We don't have to explain the issue, but we
should at the very least tell people where to find an explanation of
the issue.
---
 pod/perlfunc.pod |  134 ++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 131 insertions(+), 3 deletions(-)

diff --git a/pod/perlfunc.pod b/pod/perlfunc.pod
index e619424..53c8891 100644
--- a/pod/perlfunc.pod
+++ b/pod/perlfunc.pod
@@ -430,6 +430,8 @@ C<-x $file && -w _ && -f _>. (This is only fancy fancy: if you use
 the return value of C<-f $file> as an argument to another filetest
 operator, no special magic will happen.)
 
+Portability issues: L<perlport/x>.
+
 =item abs VALUE
 X<abs> X<absolute>
 
@@ -500,6 +502,8 @@ modulo the caveats given in L<perlipc/"Signals">.
 
 For more information see L<perlipc>.
 
+Portability issues: L<perlport/alarm>.
+
 =item atan2 Y,X
 X<atan2> X<arctangent> X<tan> X<tangent>
 
@@ -513,6 +517,8 @@ function, or use the familiar relation:
 The return value for C<atan2(0,0)> is implementation-defined; consult
 your atan2(3) manpage for more information.
 
+Portability issues: L<perlport/atan2>.
+
 =item bind SOCKET,NAME
 X<bind>
 
@@ -612,6 +618,8 @@ but also when using read(), seek(), sysread(), syswrite() and tell()
 in L<perlvar> for how to manually set your input and output
 line-termination sequences.
 
+Portability issues: L<perlport/binmode>.
+
 =item bless REF,CLASSNAME
 X<bless>
 
@@ -761,6 +769,8 @@ module:
     chmod S_IRWXU|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH, @executables;
     # Identical to the chmod 0755 of the example above.
 
+Portability issues: L<perlport/chmod>.
+
 =item chomp VARIABLE
 X<chomp> X<INPUT_RECORD_SEPARATOR> X<$/> X<newline> X<eol>
 
@@ -864,6 +874,8 @@ On POSIX systems, you can detect this condition this way:
     use POSIX qw(sysconf _PC_CHOWN_RESTRICTED);
     $can_chown_giveaway = not sysconf(_PC_CHOWN_RESTRICTED);
 
+Portability issues: L<perlport/chmod>.
+
 =item chr NUMBER
 X<chr> X<character> X<ASCII> X<Unicode>
 
@@ -898,6 +910,8 @@ change your current working directory, which is unaffected.)  For security
 reasons, this call is restricted to the superuser.  If FILENAME is
 omitted, does a C<chroot> to C<$_>.
 
+Portability issues: L<perlport/chroot>.
+
 =item close FILEHANDLE
 X<close>
 
@@ -1089,6 +1103,8 @@ the string back to an eight-bit byte string before calling crypt()
 (on that copy).  If that works, good.  If not, crypt() dies with
 C<Wide character in crypt>.
 
+Portability issues: L<perlport/crypt>.
+
 =item dbmclose HASH
 X<dbmclose>
 
@@ -1096,6 +1112,8 @@ X<dbmclose>
 
 Breaks the binding between a DBM file and a hash.
 
+Portability issues: L<perlport/dbmclose>.
+
 =item dbmopen HASH,DBNAME,MASK
 X<dbmopen> X<dbm> X<ndbm> X<sdbm> X<gdbm>
 
@@ -1139,6 +1157,8 @@ before you call dbmopen():
     dbmopen(%NS_Hist, "$ENV{HOME}/.netscape/history.db")
         or die "Can't open netscape history file: $!";
 
+Portability issues: L<perlport/dbmopen>.
+
 =item default BLOCK
 
 Within a C<foreach> or a C<given>, a C<default> BLOCK acts like a C<when>
@@ -1475,6 +1495,8 @@ convert a core file into an executable. That's why you should now invoke
 it as C<CORE::dump()>, if you don't want to be warned against a possible
 typo.
 
+Portability issues: L<perlport/dump>.
+
 =item each HASH
 X<each> X<hash, iterator>
 
@@ -1805,6 +1827,8 @@ open handles to avoid lost output.
 Note that C<exec> will not call your C<END> blocks, nor will it invoke
 C<DESTROY> methods on your objects.
 
+Portability issues: L<perlport/exec>.
+
 =item exists EXPR
 X<exists> X<autovivification>
 
@@ -1899,6 +1923,8 @@ can change the exit status by modifying C<$?>. If this is a problem, you
 can call C<POSIX:_exit($status)> to avoid END and destructor processing.
 See L<perlmod> for details.
 
+Portability issues: L<perlport/exit>.
+
 =item exp EXPR
 X<exp> X<exponential> X<antilog> X<antilogarithm> X<e>
 
@@ -1944,6 +1970,8 @@ on your own, though.
     $flags = fcntl(REMOTE, F_SETFL, $flags | O_NONBLOCK)
                 or die "Can't set flags for the socket: $!\n";
 
+Portability issues: L<perlport/fcntl>.
+
 =item fileno FILEHANDLE
 X<fileno>
 
@@ -2044,6 +2072,8 @@ function lose their locks, making it seriously harder to write servers.
 
 See also L<DB_File> for other flock() examples.
 
+Portability issues: L<perlport/flock>.
+
 =item fork
 X<fork> X<child> X<parent>
 
@@ -2073,6 +2103,14 @@ if you exit, then the remote server (such as, say, a CGI script or a
 backgrounded job launched from a remote shell) won't think you're done.
 You should reopen those to F</dev/null> if it's any issue.
 
+On some platforms such as Windows, where the fork() system call is not available,
+Perl can be built to emulate fork() in the Perl interpreter. The emulation is designed to,
+at the level of the Perl program, be as compatible as possible with the "Unix" fork().
+However it has limitation that has to be considered in code intended to be portable.
+See L<perlfork> for more details.
+
+Portability issues: L<perlport/fork>.
+
 =item format
 X<format>
 
@@ -2164,6 +2202,8 @@ returns the empty string, use C<getpwuid>.
 Do not consider C<getlogin> for authentication: it is not as
 secure as C<getpwuid>.
 
+Portability issues: L<perlport/getlogin>.
+
 =item getpeername SOCKET
 X<getpeername> X<peer>
 
@@ -2186,6 +2226,8 @@ doesn't implement getpgrp(2).  If PID is omitted, returns the process
 group of the current process.  Note that the POSIX version of C<getpgrp>
 does not accept a PID argument, so only C<PID==0> is truly portable.
 
+Portability issues: L<perlport/getpgrp>.
+
 =item getppid
 X<getppid> X<parent> X<pid>
 
@@ -2198,6 +2240,8 @@ C<getppid()>, that returns a consistent value across threads. If you want
 to call the underlying C<getppid()>, you may use the CPAN module
 C<Linux::Pid>.
 
+Portability issues: L<perlport/getppid>.
+
 =item getpriority WHICH,WHO
 X<getpriority> X<priority> X<nice>
 
@@ -2205,6 +2249,8 @@ Returns the current priority for a process, a process group, or a user.
 (See C<getpriority(2)>.)  Will raise a fatal exception if used on a
 machine that doesn't implement getpriority(2).
 
+Portability issues: L<perlport/getpriority>.
+
 =item getpwnam NAME
 X<getpwnam> X<getgrnam> X<gethostbyname> X<getnetbyname> X<getprotobyname>
 X<getpwuid> X<getgrgid> X<getservbyname> X<gethostbyaddr> X<getnetbyaddr>
@@ -2376,6 +2422,8 @@ Even though it looks as though they're the same method calls (uid),
 they aren't, because a C<File::stat> object is different from
 a C<User::pwent> object.
 
+Portability issues: L<perlport/getpwnam> to L<perlport/endservent>.
+
 =item getsockname SOCKET
 X<getsockname>
 
@@ -2421,6 +2469,7 @@ Here's an example to test whether Nagle's algorithm is enabled on a socket:
     my $nodelay = unpack("I", $packed);
     print "Nagle's algorithm is turned ", $nodelay ? "off\n" : "on\n";
 
+Portability issues: L<perlport/getsockopt>.
 
 =item given EXPR BLOCK
 X<given>
@@ -2475,6 +2524,8 @@ Beginning with v5.6.0, this operator is implemented using the standard
 C<File::Glob> extension.  See L<File::Glob> for details, including
 C<bsd_glob> which does not treat whitespace as a pattern separator.
 
+Portability issues: L<perlport/glob>.
+
 =item gmtime EXPR
 X<gmtime> X<UTC> X<Greenwich>
 
@@ -2487,7 +2538,7 @@ Note: When called in list context, $isdst, the last value
 returned by gmtime, is always C<0>.  There is no
 Daylight Saving Time in GMT.
 
-See L<perlport/gmtime> for portability concerns.
+Portability issues: L<perlport/gmtime>.
 
 =item goto LABEL
 X<goto> X<jump> X<jmp>
@@ -2664,6 +2715,8 @@ system:
 The special string C<"0 but true"> is exempt from B<-w> complaints
 about improper numeric conversions.
 
+Portability issues: L<perlport/ioctl>.
+
 =item join EXPR,LIST
 X<join>
 
@@ -2774,6 +2827,15 @@ signal the current process group and -1 will signal all processes.
 
 See L<perlipc/"Signals"> for more details.
 
+On some platforms such as Windows where the fork() system call is not available.
+Perl can be built to emulate fork() at the interpreter level.
+This emulation has limitation related to kill that has to be considered,
+for code running on Windows and in code intended to be portable.
+
+See L<perlfork> for more details.
+
+Portability issues: L<perlport/kill>.
+
 =item last LABEL
 X<last> X<break>
 
@@ -2900,6 +2962,8 @@ X<link>
 Creates a new filename linked to the old filename.  Returns true for
 success, false otherwise.
 
+Portability issues: L<perlport/link>.
+
 =item listen SOCKET,QUEUESIZE
 X<listen>
 
@@ -2993,8 +3057,6 @@ try for example:
 Note that the C<%a> and C<%b>, the short forms of the day of the week
 and the month of the year, may not necessarily be three characters wide.
 
-See L<perlport/localtime> for portability concerns.
-
 The L<Time::gmtime> and L<Time::localtime> modules provide a convenient,
 by-name access mechanism to the gmtime() and localtime() functions,
 respectively.
@@ -3002,6 +3064,8 @@ respectively.
 For a comprehensive date and time representation look at the
 L<DateTime> module on CPAN.
 
+Portability issues: L<perlport/localtime>.
+
 =item lock THING
 X<lock>
 
@@ -3044,6 +3108,8 @@ information, please see the documentation for C<stat>.
 
 If EXPR is omitted, stats C<$_>.
 
+Portability issues: L<perlport/lstat>.
+
 =item m//
 
 The match operator.  See L<perlop/"Regexp Quote-Like Operators">.
@@ -3168,6 +3234,8 @@ C<"0 but true"> for zero, or the actual return value otherwise.  See also
 L<perlipc/"SysV IPC"> and the documentation for C<IPC::SysV> and
 C<IPC::Semaphore>.
 
+Portability issues: L<perlport/msgctl>.
+
 =item msgget KEY,FLAGS
 X<msgget>
 
@@ -3176,6 +3244,8 @@ id, or C<undef> on error.  See also
 L<perlipc/"SysV IPC"> and the documentation for C<IPC::SysV> and
 C<IPC::Msg>.
 
+Portability issues: L<perlport/msgget>.
+
 =item msgrcv ID,VAR,SIZE,TYPE,FLAGS
 X<msgrcv>
 
@@ -3188,6 +3258,8 @@ Taints the variable.  Returns true if successful, false
 on error.  See also L<perlipc/"SysV IPC"> and the documentation for
 C<IPC::SysV> and C<IPC::SysV::Msg>.
 
+Portability issues: L<perlport/msgrcv>.
+
 =item msgsnd ID,MSG,FLAGS
 X<msgsnd>
 
@@ -3199,6 +3271,8 @@ C<pack("l! a*", $type, $message)>.  Returns true if successful,
 false on error.  See also the C<IPC::SysV>
 and C<IPC::SysV::Msg> documentation.
 
+Portability issues: L<perlport/msgsnd>.
+
 =item my EXPR
 X<my>
 
@@ -3708,6 +3782,8 @@ yourself and inspect the return value.
 
 See L</seek> for some details about mixing reading and writing.
 
+Portability issues: L<perlport/open>.
+
 =item opendir DIRHANDLE,EXPR
 X<opendir>
 
@@ -4826,6 +4902,8 @@ implemented.  If not, raises an exception.  If there is a system
 error, returns the undefined value and sets C<$!> (errno).  If EXPR is
 omitted, uses C<$_>.
 
+Portability issues: L<perlport/readlink>.
+
 =item readpipe EXPR
 
 =item readpipe
@@ -4959,6 +5037,8 @@ rename(2) manpage or equivalent system documentation for details.
 For a platform independent C<move> function look at the L<File::Copy>
 module.
 
+Portability issues: L<perlport/rename>.
+
 =item require VERSION
 X<require>
 
@@ -5219,6 +5299,8 @@ X<rewinddir>
 Sets the current position to the beginning of the directory for the
 C<readdir> routine on DIRHANDLE.
 
+Portability issues: L<perlport/rewinddir>.
+
 =item rindex STR,SUBSTR,POSITION
 X<rindex>
 
@@ -5377,6 +5459,8 @@ methods, preferring to write the last example as:
     use IO::Handle;
     STDERR->autoflush(1);
 
+Portability issues: L<perlport/select>.
+
 =item select RBITS,WBITS,EBITS,TIMEOUT
 X<select>
 
@@ -5441,6 +5525,8 @@ B<WARNING>: One should not attempt to mix buffered I/O (like C<read>
 or <FH>) with C<select>, except as permitted by POSIX, and even
 then only on POSIX systems.  You have to use C<sysread> instead.
 
+Portability issues: L<perlport/select>.
+
 =item semctl ID,SEMNUM,CMD,ARG
 X<semctl>
 
@@ -5457,6 +5543,8 @@ short integers, which may be created with C<pack("s!",(0)x$nsem)>.
 See also L<perlipc/"SysV IPC">, C<IPC::SysV>, C<IPC::Semaphore>
 documentation.
 
+Portability issues: L<perlport/semctl>.
+
 =item semget KEY,NSEMS,FLAGS
 X<semget>
 
@@ -5465,6 +5553,8 @@ the undefined value on error.  See also
 L<perlipc/"SysV IPC">, C<IPC::SysV>, C<IPC::SysV::Semaphore>
 documentation.
 
+Portability issues: L<perlport/semget>.
+
 =item semop KEY,OPSTRING
 X<semop>
 
@@ -5483,6 +5573,8 @@ To signal the semaphore, replace C<-1> with C<1>.  See also
 L<perlipc/"SysV IPC">, C<IPC::SysV>, and C<IPC::SysV::Semaphore>
 documentation.
 
+Portability issues: L<perlport/semop>.
+
 =item send SOCKET,MSG,FLAGS,TO
 X<send>
 
@@ -5513,6 +5605,8 @@ it defaults to C<0,0>.  Note that the BSD 4.2 version of C<setpgrp> does not
 accept any arguments, so only C<setpgrp(0,0)> is portable.  See also
 C<POSIX::setsid()>.
 
+Portability issues: L<perlport/setpgrp>.
+
 =item setpriority WHICH,WHO,PRIORITY
 X<setpriority> X<priority> X<nice> X<renice>
 
@@ -5520,6 +5614,8 @@ Sets the current priority for a process, a process group, or a user.
 (See setpriority(2).)  Raises an exception when used on a machine
 that doesn't implement setpriority(2).
 
+Portability issues: L<perlport/setpriority>.
+
 =item setsockopt SOCKET,LEVEL,OPTNAME,OPTVAL
 X<setsockopt>
 
@@ -5534,6 +5630,8 @@ An example disabling Nagle's algorithm on a socket:
     use Socket qw(IPPROTO_TCP TCP_NODELAY);
     setsockopt($socket, IPPROTO_TCP, TCP_NODELAY, 1);
 
+Portability issues: L<perlport/setsockopt>.
+
 =item shift ARRAY
 X<shift>
 
@@ -5571,6 +5669,8 @@ structure.  Returns like ioctl: C<undef> for error; "C<0> but
 true" for zero; and the actual return value otherwise.
 See also L<perlipc/"SysV IPC"> and C<IPC::SysV> documentation.
 
+Portability issues: L<perlport/shmctl>.
+
 =item shmget KEY,SIZE,FLAGS
 X<shmget>
 
@@ -5578,6 +5678,8 @@ Calls the System V IPC function shmget.  Returns the shared memory
 segment id, or C<undef> on error.
 See also L<perlipc/"SysV IPC"> and C<IPC::SysV> documentation.
 
+Portability issues: L<perlport/shmget>.
+
 =item shmread ID,VAR,POS,SIZE
 X<shmread>
 X<shmwrite>
@@ -5593,6 +5695,8 @@ SIZE bytes.  Return true if successful, false on error.
 shmread() taints the variable. See also L<perlipc/"SysV IPC">,
 C<IPC::SysV>, and the C<IPC::Shareable> module from CPAN.
 
+Portability issues: L<perlport/shmread> and L<perlport/shmwrite>.
+
 =item shutdown SOCKET,HOW
 X<shutdown>
 
@@ -5697,6 +5801,8 @@ See L<perlipc> for an example of socketpair use.  Perl 5.8 and later will
 emulate socketpair using IP sockets to localhost if your system implements
 sockets but not socketpair.
 
+Portability issues: L<perlport/socketpair>.
+
 =item sort SUBNAME LIST
 X<sort> X<qsort> X<quicksort> X<mergesort>
 
@@ -6605,6 +6711,8 @@ See your native chmod(2) and stat(2) documentation for more details
 about the C<S_*> constants.  To get status info for a symbolic link
 instead of the target file behind the link, use the C<lstat> function.
 
+Portability issues: L<perlport/stat>.
+
 =item state EXPR
 X<state>
 
@@ -6774,6 +6882,8 @@ use eval:
 
     $symlink_exists = eval { symlink("",""); 1 };
 
+Portability issues: L<perlport/symlink>.
+
 =item syscall NUMBER, LIST
 X<syscall> X<system call>
 
@@ -6809,6 +6919,8 @@ number of the read end of the pipe it creates, but there is no way
 to retrieve the file number of the other end.  You can avoid this
 problem by using C<pipe> instead.
 
+Portability issues: L<perlport/syscall>.
+
 =item sysopen FILEHANDLE,FILENAME,MODE
 X<sysopen>
 
@@ -6872,6 +6984,8 @@ library, or perhaps using the POSIX::open() function.
 
 See L<perlopentut> for a kinder, gentler explanation of opening files.
 
+Portability issues: L<perlport/sysopen>.
+
 =item sysread FILEHANDLE,SCALAR,LENGTH,OFFSET
 X<sysread>
 
@@ -7007,6 +7121,8 @@ See L<perlop/"`STRING`"> and L</exec> for details.
 Since C<system> does a C<fork> and C<wait> it may affect a C<SIGCHLD>
 handler. See L<perlipc> for details.
 
+Portability issues: L<perlport/system>.
+
 =item syswrite FILEHANDLE,SCALAR,LENGTH,OFFSET
 X<syswrite>
 
@@ -7201,6 +7317,8 @@ In scalar context, C<times> returns C<$user>.
 
 Children's times are only included for terminated children.
 
+Portability issues: L<perlport/times>.
+
 =item tr///
 
 The transliteration operator.  Same as C<y///>.  See
@@ -7221,6 +7339,8 @@ file.
 The position in the file of FILEHANDLE is left unchanged.  You may want to
 call L<seek|/"seek FILEHANDLE,POSITION,WHENCE"> before writing to the file.
 
+Portability issues: L<perlport/truncate>.
+
 =item uc EXPR
 X<uc> X<uppercase> X<toupper>
 
@@ -7288,6 +7408,8 @@ not trying to restrict access for yourself, returns C<undef>.
 Remember that a umask is a number, usually given in octal; it is I<not> a
 string of octal digits.  See also L</oct>, if all you have is a string.
 
+Portability issues: L<perlport/umask>.
+
 =item undef EXPR
 X<undef> X<undefine>
 
@@ -7598,6 +7720,8 @@ files.  On systems that don't support futimes(2), passing filehandles raises
 an exception.  Filehandles must be passed as globs or glob references to be
 recognized; barewords are considered filenames.
 
+Portability issues: L<perlport/utime>.
+
 =item values HASH
 X<values>
 
@@ -7891,6 +8015,8 @@ being automatically reaped, as described in L<perlipc>.
 If you use wait in your handler for $SIG{CHLD} it may accidentally for the
 child created by qx() or system(). See L<perlipc> for details.
 
+Portability issues: L<perlport/wait>.
+
 =item waitpid PID,FLAGS
 X<waitpid>
 
@@ -7916,6 +8042,8 @@ Note that on some systems, a return value of C<-1> could mean that child
 processes are being automatically reaped.  See L<perlipc> for details,
 and for other examples.
 
+Portability issues: L<perlport/waitpid>.
+
 =item wantarray
 X<wantarray> X<context>
 
-- 
1.7.3.1.msysgit.0

@p5pRT
Copy link
Author

p5pRT commented Jun 7, 2011

From Bo.Johansson@lsn.se

0001-Add-information-about-portability-caveats-related-to.patch
From f20405c643e7886ae013baee00bf2763ad65bc1d Mon Sep 17 00:00:00 2001
From: bojilund <bo.johansso@lsn.se>
Date: Tue, 7 Jun 2011 10:24:43 +0200
Subject: [PATCH] Add information about portability caveats related to using kill on forked process.

The outcome of kill on a pseudo-process in Windows is unpredictable
and it should not be used except under dire circumstances.
The process which implements the pseudo-processes can be blocked
and the Perl interpreter hangs.
---
 pod/perlfork.pod |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/pod/perlfork.pod b/pod/perlfork.pod
index 709d053..4257b87 100644
--- a/pod/perlfork.pod
+++ b/pod/perlfork.pod
@@ -78,10 +78,12 @@ and return its status.
 =item kill()
 
 C<kill('KILL', ...)> can be used to terminate a pseudo-process by
-passing it the ID returned by fork().  This should not be used except
+passing it the ID returned by fork(). The outcome of kill on a pseudo-process
+is unpredictable and it should not be used except
 under dire circumstances, because the operating system may not
 guarantee integrity of the process resources when a running thread is
-terminated.  Note that using C<kill('KILL', ...)> on a
+terminated.  The process which implements the pseudo-processes can be blocked
+and the Perl interpreter hangs. Note that using C<kill('KILL', ...)> on a
 pseudo-process() may typically cause memory leaks, because the thread
 that implements the pseudo-process does not get a chance to clean up
 its resources.
@@ -307,6 +309,12 @@ are expected to be fixed for thread-safety.
 
 =back
 
+=head1 PORTABILITY CAVEATS
+
+In portable Perl code, C<kill(9, $child)> must not be used on forked processes.
+Killing a forked process is unsafe and have unpredictable results.
+See L</kill()>, above.
+
 =head1 BUGS
 
 =over 8
-- 
1.7.3.1.msysgit.0

@p5pRT
Copy link
Author

p5pRT commented Jun 7, 2011

From @cpansprout

On Tue Jun 07 01​:44​:40 2011, boilund wrote​:

-----Original Message-----
From​: Father Chrysostomos via RT
Sent​: Monday, June 06, 2011 5​:38 AM
To​: Bo.Johansson@​lsn.se
Subject​: [perl #91526] [PATCH] Improve documentation to support
portability

On Mon May 30 19​:51​:51 2011, boilund wrote​:

Father Chrysostomos, thank you for answering!

I am quit sure that the "small cost" to add some "cluttering"
will pay off as improved portability of Perl code.
When selecting a function to use you should be aware of portability
issues
for the functions.

Fair enough. I tried applying your perlfunc patch, but it seems to have
been scrambled by your mail program (initial spaces before each
unmodified line have been stripped). Could you resend it as an
attachment?

Patch is attached as​:
0001-Improve-documentation-to-support-portability.patch

I have used Perl in many years and have not observed the "item
kill()".
Even if I had observed it I had probably not understood the
consequences.
I strongly believes that many more also do not understand the
consequences
of
using kill on a forked process in Windows and other non Unix/Linux
operating
systems.

Concrete rules and recommendations what to do is needed.

Some reasons why it is important to highlight the portability issues
with
kill are​:

...

I think it would be better to add something like this​:

=head1 PORTABILITY CAVEATS

Killing a pseudo-process may have unpredictable results. See
L</kill()>, above.

What do you think?

OK!

If the existing kill() entry is not sufficient, would you be willing to
expand on that, instead of creating a separate entry?

Proposal for changes to perlfork in the attached patch​:
0001-Add-information-about-portability-caveats-related-to.patch

Thank you. I’ve applied those as commits ea9eb35 and bd1171b.

@p5pRT
Copy link
Author

p5pRT commented Jun 7, 2011

@cpansprout - Status changed from 'open' to 'resolved'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant