I recently fielded a request to have getppid() in perl on VMS.
Looking into the matter I could not quite tell why we had
d_getppid='undef' hard coded in our config.sh, but I can
only assume that it was not available to some older compiler
version(?). In the C RTL getppid() was documented in publication
number AA-PUNEE-TK which corresponded to DEC C V5.2.
Note that the enclosed patch plays it safe by having configure.com
do a test compilation (although it might not be prototyped in unistd.h
in other places - getppid is in sys/unistd.h and unistd.h in gcc 2.95
on cygwin at least).
With the enclosed patch on 5.8.0-RC2 I obtain the following
results:
$ perl -e "print getppid(),""\n$$"";"
0
677823586
$ spawn
%DCL-S-SPAWNED, process PPRYMMER_1 spawned
%DCL-S-ATTACHED, terminal now attached to process PPRYMMER_1
$ perl -e "print getppid(),""\n$$"";"
677823586
677785218
Which seems reasonable. I also obtained these results for
`mms test`:
All tests successful.
u=111.9 s=0 cu=0 cs=0 scripts=632 tests=64002
diff -ru perl-5_8_0-RC2_orig/configure.com perl-5_8_0-RC2/configure.com
--- perl-5_8_0-RC2_orig/configure.com Sun Jun 23 20:19:11 2002
+++ perl-5_8_0-RC2/configure.com Sun Jun 23 20:20:02 2002
@@ -3374,6 +3374,25 @@
$ GOSUB inhdr
$ i_unistd = tmp
$!
+$! do we have getppid()?
+$!
+$ IF i_unistd .EQS. "define"
+$ THEN
+$ OS
+$ WS "#include <stdio.h>"
+$ WS "#include <unistd.h>"
+$ WS "int main() {"
+$ WS "printf(""%d\n"",getppid());"
+$ WS "return(0);"
+$ WS "}"
+$ CS
+$ tmp = "getppid"
+$ GOSUB inlibc
+$ d_getppid = tmp
+$ ELSE
+$ d_getppid = "undef"
+$ ENDIF
+$!
$!: see if this is a libutil.h system
$!
$ tmp = "libutil.h"
@@ -5253,7 +5272,7 @@
$ WC "d_getpgid='undef'"
$ WC "d_getpgrp2='undef'"
$ WC "d_getpgrp='undef'"
-$ WC "d_getppid='undef'"
+$ WC "d_getppid='" + d_getppid + "'"
$ WC "d_getprior='undef'"
$ WC "d_getprotoprotos='" + d_getprotoprotos + "'"
$ WC "d_getprpwnam='undef'"
diff -ru perl-5_8_0-RC2_orig/pod/perlport.pod perl-5_8_0-RC2/pod/perlport.pod
--- perl-5_8_0-RC2_orig/pod/perlport.pod Sun Jun 23 20:19:38 2002
+++ perl-5_8_0-RC2/pod/perlport.pod Sun Jun 23 20:20:20 2002
@@ -1584,7 +1584,10 @@
=item getppid
-Not implemented. (S<Mac OS>, Win32, VMS, S<RISC OS>)
+Not implemented. (S<Mac OS>, Win32, older versions of VMS, S<RISC OS>)
+
+Returns 0 to indicate that the calling process does not have
+a parent process. (Recent versions of VMS)
=item getpriority WHICH,WHO
@@ -1794,7 +1797,7 @@
=item setgrent
-Not implemented. (S<Mac OS>, MPE/iX, VMS, Win32, VMS, S<RISC OS>)
+Not implemented. (S<Mac OS>, MPE/iX, VMS, Win32, S<RISC OS>)
=item setpgrp PID,PGRP
End of Patch.
Would there be any objection to putting that into 5.8.0?
Peter Prymmer