diff options
| author | czjstmax <jstmaxlol@disroot.org> | 2026-01-31 15:10:20 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-01-31 15:10:20 +0100 |
| commit | d2e2617dec584884b92eb452f377b20c0bf8f321 (patch) | |
| tree | d7cdc28d1a83f16a0fc7e945963aa070bfa9d3e4 /std/process.zc | |
| parent | 0427d254207a69e394499d1abaea768f484f1cb5 (diff) | |
| parent | 051400c70a4d5384923113cfbcbc69e8e58d27a0 (diff) | |
Merge pull request #1 from z-libs/main
Merge newer updates
Diffstat (limited to 'std/process.zc')
| -rw-r--r-- | std/process.zc | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/std/process.zc b/std/process.zc index d0b09a9..3ce43b6 100644 --- a/std/process.zc +++ b/std/process.zc @@ -5,8 +5,16 @@ import "./mem.zc"; import "./string.zc"; import "./option.zc"; -raw { - void *_z_popen(char *command, char *type) { +include <stdio.h> +include <stdlib.h> + +// system() can be externed directly with const char* +extern fn system(command: const char*) -> int; + +// Minimal raw block: only for opaque FILE* types +// popen/pclose/fgets use FILE* which conflicts with void* +raw { + void *_z_popen(const char *command, const char *type) { return (void *)popen(command, type); } @@ -17,16 +25,11 @@ raw { char *_z_fgets(char *s, int size, void *stream) { return fgets(s, size, (FILE *)stream); } - - int _z_system(char *command) { - return system(command); - } } -extern fn _z_popen(command: char*, type: char*) -> void*; +extern fn _z_popen(command: const char*, type: const char*) -> void*; extern fn _z_pclose(stream: void*) -> int; extern fn _z_fgets(s: char*, size: int, stream: void*) -> char*; -extern fn _z_system(command: char*) -> int; struct Output { stdout: String; @@ -105,7 +108,7 @@ impl Command { fn status(self) -> int { let cmd_str = self._build_cmd(); - let code = _z_system(cmd_str.c_str()); + let code = system(cmd_str.c_str()); cmd_str.free(); return code; } |
