On Mon, May 02, 2005 at 10:39:12AM -0700, Rafael Garcia-Suarez wrote: > For perls where pids and ppids are cached, when the ppid of > the perl process becomes 1, refresh the ppid cache (this may > indicate that the parent process has died.)
> --- perl/pp_sys.c#393~24339~ Wed Apr 27 13:24:30 2005
> +++ perl/pp_sys.c Mon May 2 10:10:19 2005
> @@ -4377,6 +4377,12 @@
> #ifdef HAS_GETPPID
> dSP; dTARGET;
> # ifdef THREADS_HAVE_PIDS
> + {
> + IV cur_ppid = getppid();
> + if (cur_ppid == 1)
> + /* maybe the parent process has died. Refresh ppid cache */
> + PL_ppid = cur_ppid;
> + }
> XPUSHi( PL_ppid );
cur_ppid should be rather Pid_t, not IV. Besides this, you can
eliminate the variable and even save a system call in certain cases.
Anyway I'm sorry about this really little patch. :)
--- perl-5.9.3.24699/pp_sys.c- 2005-06-03 09:01:34 +0000
+++ perl-5.9.3.24699/pp_sys.c 2005-06-04 03:43:02 +0000
@@ -4372,12 +4372,9 @@ PP(pp_getppid)
#ifdef HAS_GETPPID
dSP; dTARGET;
# ifdef THREADS_HAVE_PIDS
- {
- IV cur_ppid = getppid();
- if (cur_ppid == 1)
- /* maybe the parent process has died. Refresh ppid cache */
- PL_ppid = cur_ppid;
- }
+ if (PL_ppid != 1 && getppid() == 1)
+ /* the parent process has died. Refresh ppid cache */
+ PL_ppid = 1;
XPUSHi( PL_ppid );
# else
XPUSHi( getppid() );
End of patch
pgpEfG2dY0oya.pgp
Description: PGP signature
