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

Re: [tyndur-devel] [PATCH 5/5] Pascal-RTL: ExecuteProcess



On Sun, May 31 20:22, Kevin Wolf wrote:
> + Pascal-RTL: Implementierung von sysutils.ExecuteProcess
> 
> Signed-off-by: Kevin Wolf <kevin@xxxxxxxxxx>
> ---
>  src/modules/pas/lib/rtl/sysutils.pp |   37 +++++++++++++++++++++++++++++++---
>  1 files changed, 33 insertions(+), 4 deletions(-)
> 
> diff --git a/src/modules/pas/lib/rtl/sysutils.pp b/src/modules/pas/lib/rtl/sysutils.pp
> index ac1e5dc..934f88b 100644
> --- a/src/modules/pas/lib/rtl/sysutils.pp
> +++ b/src/modules/pas/lib/rtl/sysutils.pp
> @@ -51,6 +51,9 @@ function c_fseek(f: longint; offset, whence: longint): longint; cdecl; external
>  
>  function c_feof(f: longint): boolean; cdecl; external name 'feof';
>  
> +function c_init_execute(cmd: PChar): dword; cdecl; external name 'init_execute';
> +function c_waitpid(pid: integer; status: Pointer; flags: integer): integer; cdecl; external name 'waitpid';
> +
>  type
>      DirEntry = record
>          name:   array [1..32] of char;
> @@ -162,14 +165,40 @@ begin
>  end;    
>  
>  function ExecuteProcess(const path: AnsiString;const comline: AnsiString):LongInt;
> +var
> +    cmdline: String;
> +    ret, pid: integer;
> +    status: integer;
>  begin
> -    Result := 0; // FIXME
> -end;    
> +    cmdline := path + ' ' + comline + #0;
> +
> +    pid := c_init_execute(@cmdline[1]);
> +    ret := c_waitpid(pid, @status, 0);
> +
> +    if ret = -1 then begin
> +        raise EOSError.create('Konnte Programm ' + path + 'nicht ausf??hren');
> +    end;

Hm, willst du das if nicht eher hinter das while schieben?

> +
> +    while (ret <> pid) and (ret <> -1) do begin
> +        yield;
> +        ret := c_waitpid(pid, @status, 0);
> +    end;
> +
> +    ExecuteProcess := status;
> +end;
>  
>  function ExecuteProcess(const path: AnsiString;const comline: Array Of AnsiString):LongInt;
> +var
> +    args: String;
> +    i: integer;
>  begin
> -    Result := 0; // FIXME
> -end;    
> +    args := '';
> +    for i := Low(comline) to High(comline) do begin
> +        args := args + comline[i];

Hm, Leerzeichen brauchts hier keine?

> +    end;
> +
> +    ExecuteProcess := ExecuteProcess(path, args);
> +end;
>  
>  procedure GetLocalTime(var systemtime: TSystemTime);
>  begin

Sonst sieht das gut aus. Wenn du das noch anpasst, falls nötig, kannst
du es einchecken.

Acked-by: Antoine Kaufmann <toni@xxxxxxxxxx>

-- 
Antoine Kaufmann
<toni@xxxxxxxxxxxxxxxx>

Attachment: pgpAALe3SfE8E.pgp
Description: PGP signature