summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: f96102d)
raw | patch | inline | side by side (parent: f96102d)
author | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Sun, 8 Mar 2020 12:45:31 +0000 (15:45 +0300) | ||
committer | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Sun, 8 Mar 2020 12:45:31 +0000 (15:45 +0300) |
src/posix/generic/Dsw/Mod/HostProcs.cp | patch | blob | history |
index 2aa47588c7f01b23520cbb15b40d655d14a38486..8516697aa512bd6390d32152d1b2a802e5ea5519 100644 (file)
PROCEDURE (p: Process) Execute* (OUT ok: BOOLEAN);
TYPE
UString = POINTER [untagged] TO ARRAY [untagged] OF SHORTCHAR;
- SUString = POINTER TO ARRAY OF UString;
+ SUString = POINTER [untagged] TO ARRAY [untagged] OF UString;
VAR
- i, j: INTEGER; pid: unistd.pid_t; res: unistd.int; argv: SUString;
+ i, j, adr: INTEGER; pid: unistd.pid_t; res: unistd.int; argv: SUString;
BEGIN
ASSERT(p.pid = -1, 20);
ASSERT(p.argv # NIL, 21);
- NEW(argv, LEN(p.argv) + 1);
+ argv := SYSTEM.VAL(SUString, stdlib.malloc((LEN(p.argv) + 1)) * SIZE(UString));
FOR i := 0 TO LEN(p.argv) - 1 DO
argv[i] := SYSTEM.VAL(UString, SYSTEM.ADR(p.argv[i, 0]))
END;
+ argv[i] := NIL;
pid := unistd.fork();
IF pid = 0 THEN
res := unistd.execv(argv[0], argv);
p.argv := NIL; (* or save it for debugging and reuse? *)
p.pid := pid;
ok := TRUE
- END
+ END;
+ stdlib.free(SYSTEM.ADR(argv[0]))
END Execute;
PROCEDURE (p: Process) Terminate* (OUT ok: BOOLEAN);