summaryrefslogtreecommitdiff
path: root/source/kit/process.h
diff options
context:
space:
mode:
authorMitya Selivanov <automainint@guattari.tech>2024-02-11 18:17:33 +0100
committerMitya Selivanov <automainint@guattari.tech>2024-02-11 18:17:33 +0100
commitdf00df5a7a5bcd9076d4423128ea014ab3535626 (patch)
tree337e62f8ca39b19b250b155a3fbeb495384e356b /source/kit/process.h
parent80da54bb97c279aa60fb77a9bbad9baa0f2e4477 (diff)
downloadsaw-df00df5a7a5bcd9076d4423128ea014ab3535626.zip
Update kit
Diffstat (limited to 'source/kit/process.h')
-rw-r--r--source/kit/process.h74
1 files changed, 74 insertions, 0 deletions
diff --git a/source/kit/process.h b/source/kit/process.h
new file mode 100644
index 0000000..9ee7ccf
--- /dev/null
+++ b/source/kit/process.h
@@ -0,0 +1,74 @@
+// TODO
+//
+
+#ifndef KIT_PROCESS_H
+#define KIT_PROCESS_H
+
+#include "types.h"
+#include "string_ref.h"
+
+#if !defined(_WIN32) || defined(__CYGWIN__)
+# include <unistd.h>
+#else
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+enum {
+ KIT_PROCESS_NO_ARGUMENTS = 1,
+ KIT_PROCESS_NO_ENVIRONMENT = (1 << 1),
+ KIT_PROCESS_NO_PIPES = (1 << 2),
+ KIT_PROCESS_FORK = (1 << 3),
+};
+
+typedef struct {
+ s32 status;
+ u8 exit_code;
+ b8 current_is_forked;
+#if !defined(_WIN32) || defined(__CYGWIN__)
+ b8 _ready;
+ b8 _running;
+ pid_t _id;
+ i32 _stdin;
+ i32 _stdout;
+ i32 _stderr;
+#else
+#endif
+} kit_process_t;
+
+typedef struct {
+ kit_str_t name;
+ kit_str_t value;
+} kit_process_env_var_t;
+
+typedef KIT_AR(kit_str_t) kit_process_args_t;
+typedef KIT_AR(kit_process_env_var_t) kit_process_env_t;
+
+typedef struct {
+ u32 flags;
+ kit_str_t file_name;
+ kit_process_args_t command_line;
+ kit_process_env_t environment;
+ kit_str_t working_directory;
+} kit_process_info_t;
+
+s32 kit_process_init(kit_process_t *p, kit_process_info_t info);
+void kit_process_cleanup(kit_process_t *p);
+
+i64 kit_process_write_stdin(kit_process_t *p, kit_str_t in_data);
+i64 kit_process_read_stdout(kit_process_t *p, kit_str_t out_data);
+i64 kit_process_read_stderr(kit_process_t *p, kit_str_t out_data);
+s32 kit_process_terminate(kit_process_t *p);
+b8 kit_process_alive(kit_process_t *p);
+s32 kit_process_wait(kit_process_t *p);
+
+#ifdef __cplusplus
+}
+#endif
+
+#ifndef KIT_DISABLE_SHORT_NAMES
+#endif
+
+#endif