summaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorLeo Tenenbaum <pommicket@gmail.com>2021-02-16 11:07:46 -0500
committerLeo Tenenbaum <pommicket@gmail.com>2021-02-16 11:07:46 -0500
commitfcb74112105e45ffc0a26aca7d952e84b05c782c (patch)
tree2696401189b65229c4a5f64f9b98d0e276cb277e /main.c
parentacfbdf2359f533f88e284b5f5219b5c671992fc7 (diff)
got WNOHANG to work
Diffstat (limited to 'main.c')
-rw-r--r--main.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/main.c b/main.c
index 8c6308b..d879cb7 100644
--- a/main.c
+++ b/main.c
@@ -146,14 +146,13 @@ int main(int argc, char **argv) {
#endif
setlocale(LC_ALL, ""); // allow unicode
- process_init();
+ char *program = "/usr/bin/sleep";
+ char *args[] = {program, "5", NULL};
+ Process process = {0}, *proc = &process;
- char *program = "/usr/bin/make";
- char *args[] = {program, NULL};
- Process *process = process_exec(program, args);
- if (!process) {
- printf("Error: %s\n", process_geterr());
+ if (!process_exec(proc, program, args)) {
+ printf("Error: %s\n", process_geterr(proc));
return EXIT_FAILURE;
}
#if 1
@@ -161,9 +160,9 @@ int main(int argc, char **argv) {
i64 bytes = 0;
char buf[256];
while (1) {
- bytes = process_read(process, buf, sizeof buf);
+ bytes = process_read(proc, buf, sizeof buf);
if (bytes == -2) {
- printf("Error: %s\n", process_geterr());
+ printf("Error: %s\n", process_geterr(proc));
} else if (bytes == -1) {
usleep(1000);
} else if (bytes == 0) {
@@ -176,7 +175,7 @@ int main(int argc, char **argv) {
{
char message[256];
while (1) {
- int status = process_check_status(process, message, sizeof message);
+ int status = process_check_status(proc, message, sizeof message);
if (status == -1) {
printf("%s!!!\n",message);
break;