[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Lost] [Patch 2/3] Pascal-RTL: exec richtig implementieren



! Pascal-RTL: dos: exec wartet bis das gestartete Prorgramm beendet wird

Index: trunk/src/modules/pas/lib/dos/dos.pas
===================================================================
--- trunk.orig/src/modules/pas/lib/dos/dos.pas	2008-04-20 13:58:28.000000000 +0200
+++ trunk/src/modules/pas/lib/dos/dos.pas	2008-04-20 14:24:32.000000000 +0200
@@ -91,6 +91,7 @@
 function c_directory_read(handle: Pointer): PDirEntry; cdecl; external name 'directory_read';
 
 function c_init_execute(cmd: PChar): dword; cdecl; external name 'init_execute';
+function c_waitpid(pid: dword; status: Pointer; flags: dword): dword; cdecl; external name 'waitpid';
 
 function LastDelimiter(const Delimiters, S: string): Integer;
 var
@@ -341,11 +342,17 @@
 procedure Exec(const path: PathStr; const args: ComStr);
 var
     cmdline: String;
+    ret, pid: integer;
+    status: integer;
 begin
     cmdline := path + ' ' + args + #0;
-    c_init_execute(@cmdline[1]);
 
-    // FIXME while (get_parent_pid(pid) != 0) yield();
+    pid := c_init_execute(@cmdline[1]);
+    ret := c_waitpid(pid, @status, 0);
+    while (ret <> pid) and (ret <> -1) do begin
+        yield;
+        ret := c_waitpid(pid, @status, 0);
+    end;
 end;
 
 Procedure GetDate (var year, month, mday, wday: word);
Index: trunk/src/modules/pas/lib/rtl/system.pas
===================================================================
--- trunk.orig/src/modules/pas/lib/rtl/system.pas	2008-04-20 14:21:21.000000000 +0200
+++ trunk/src/modules/pas/lib/rtl/system.pas	2008-04-20 14:22:23.000000000 +0200
@@ -55,6 +55,7 @@
 
 procedure InitMessaging; cdecl; external name 'init_messaging';
 procedure InitEnvironment; cdecl; external name 'init_envvars';
+procedure InitWaitpid; cdecl; external name 'init_waitpid';
 function GetCmdline: PChar; cdecl; external name 'get_cmdline';
 
 { include system independent routines }
@@ -241,6 +242,7 @@
 Begin
     InitHeap;
     InitMessaging;
+    InitWaitpid;
 
     // stdin/out/err initialisieren
     repeat

--