View Issue Details

IDProjectCategoryView StatusLast Update
0000613Perl for OS/2Bugpublic2020-08-31 19:25
ReporterkomhAssigned Topsmedley 
PrioritynormalSeveritymajorReproducibilityalways
Status closedResolutionfixed 
Summary0000613: system 1(P_NOWAIT mode) does not return a correct PID
Descriptionsystem function with 1(P_NOWAIT) as its first parameter, should return a PID of child, but it returns a garbage value.
TagsNo tags attached.

Activities

komh

2014-07-10 21:04

reporter  

0001-Set-PL_statusvalue-and-return-value-correctly.patch (1,998 bytes)
From 0fd9879dc9bc8bab6d7ad39b11038764db6fb7ec Mon Sep 17 00:00:00 2001
From: KO Myung-Hun <komh@chollian.net>
Date: Wed, 18 Jun 2014 15:18:33 +0900
Subject: [PATCH] Set PL_statusvalue and return value correctly

This fixes especially the problem that system 1(P_NOWAIT) return a wrong
value instead of pid of a child.
---
 os2/os2.c |   29 +++++++++++++++++++++++++++--
 1 files changed, 27 insertions(+), 2 deletions(-)

diff --git a/os2/os2.c b/os2/os2.c
index bf01308..1452e69 100644
--- a/os2/os2.c
+++ b/os2/os2.c
@@ -1548,6 +1548,18 @@ do_spawn_ve(pTHX_ SV *really, U32 flag, U32 execf, char *inicmd, U32 addflag)
 	fcntl(2, F_SETFD, fl_stderr);
     } else if (nostderr)
        close(2);
+
+    if (execf == EXECF_SPAWN_NOWAIT || trueflag == P_NOWAIT)
+	PL_statusvalue = -1;    /* >16bits hint for pp_system() */
+    else {
+	if (rc < 0)
+	    rc = 0xFF << 8;
+	else
+	    rc <<= 8;
+
+	PL_statusvalue = rc;
+    }
+
     return rc;
 }
 
@@ -1648,6 +1660,18 @@ do_spawn3(pTHX_ char *cmd, int execf, int flag)
 		if (rc < 0)
 		    rc = -1;
 	    }
+
+	    if (execf == EXECF_SPAWN_NOWAIT || flag == P_NOWAIT)
+		PL_statusvalue = -1;    /* >16bits hint for pp_system() */
+	    else {
+		if (rc < 0)
+		    rc = 0xFF << 8;
+		else
+		    rc <<= 8;
+
+		PL_statusvalue = rc;
+	    }
+
 	    if (news)
 		Safefree(news);
 	    return rc;
@@ -1672,7 +1696,8 @@ do_spawn3(pTHX_ char *cmd, int execf, int flag)
     if (PL_Argv[0])
 	rc = do_spawn_ve(aTHX_ NULL, flag, execf, cmd, mergestderr);
     else
-    	rc = -1;
+	PL_statusvalue = rc = (execf == EXECF_SPAWN_NOWAIT || flag == P_NOWAIT)
+			      ? -1 : (0xFF << 8);
     if (news)
 	Safefree(news);
     do_execfree();
@@ -1721,7 +1746,7 @@ os2_aspawn_4(pTHX_ SV *really, register SV **args, I32 cnt, int execing)
 	    rc = do_spawn_ve(aTHX_ really, flag, execf[execing], NULL, 0);
 	}
     } else
-    	rc = -1;
+	PL_statusvalue = rc = (execing == ASPAWN_NOWAIT) ? -1 : (0xFF << 8);
     do_execfree();
     return rc;
 }
-- 
1.7.3.2

psmedley

2020-08-31 19:24

administrator   ~0003526

This will be in the next update of 5.32.0

Issue History

Date Modified Username Field Change
2014-07-10 21:04 komh New Issue
2014-07-10 21:04 komh File Added: 0001-Set-PL_statusvalue-and-return-value-correctly.patch
2020-08-31 19:24 psmedley Note Added: 0003526
2020-08-31 19:25 psmedley Assigned To => psmedley
2020-08-31 19:25 psmedley Status new => feedback
2020-08-31 19:25 psmedley Status feedback => closed
2020-08-31 19:25 psmedley Resolution open => fixed