# HG changeset patch # User Paul Boddie # Date 1705449123 -3600 # Node ID 11c3032fffcc759353fe54171bd98fd06f44e353 # Parent fb7127ee218e20ac17972ffa3cf35bfd0bf04d1e Permit exit code propagation for potential handling. diff -r fb7127ee218e -r 11c3032fffcc fsaccess/fsaccess.c --- a/fsaccess/fsaccess.c Mon Jan 15 23:44:56 2024 +0100 +++ b/fsaccess/fsaccess.c Wed Jan 17 00:52:03 2024 +0100 @@ -78,6 +78,7 @@ char **args; int num_args; + int exitcode; enum op_results op_result; /* Parse program options and initialise the argument details. */ @@ -96,7 +97,7 @@ /* Perform the requested operation. */ - op_result = run_operation(args[0], num_args - 1, &args[1]); + op_result = run_operation(args[0], num_args - 1, &args[1], &exitcode); return handle_op_result(args[0], op_result); } diff -r fb7127ee218e -r 11c3032fffcc fsaccess/op_run.c --- a/fsaccess/op_run.c Mon Jan 15 23:44:56 2024 +0100 +++ b/fsaccess/op_run.c Wed Jan 17 00:52:03 2024 +0100 @@ -56,7 +56,7 @@ if (err) { printf("Could not obtain pipe: %s\n", l4sys_errtostr(err)); - return 1; + return -1; } /* Start the process. */ @@ -66,7 +66,7 @@ if (err) { printf("Could not start process: %s\n", l4sys_errtostr(err)); - return 1; + return -1; } printf("Finished program initiation.\n"); @@ -96,9 +96,9 @@ printf("End process (flags %" pFMTnotify_flags "x values: %ld, %ld)\n", flags, values.sig, values.val); if (err) - return 1; + return -1; - return 0; + return values.val; } /* vim: tabstop=2 expandtab shiftwidth=2 diff -r fb7127ee218e -r 11c3032fffcc fsaccess/op_script.c --- a/fsaccess/op_script.c Mon Jan 15 23:44:56 2024 +0100 +++ b/fsaccess/op_script.c Wed Jan 17 00:52:03 2024 +0100 @@ -45,6 +45,7 @@ char buffer[BUFSIZE]; enum op_results op_result; int num_args; + int exitcode; char *args[MAX_ARGS]; int i, use_stdin; @@ -77,7 +78,7 @@ if (num_args >= 1) { - op_result = run_operation(args[0], num_args - 1, &args[1]); + op_result = run_operation(args[0], num_args - 1, &args[1], &exitcode); if (handle_op_result(args[0], op_result) && !use_stdin) return 1; diff -r fb7127ee218e -r 11c3032fffcc fsaccess/ops.c --- a/fsaccess/ops.c Mon Jan 15 23:44:56 2024 +0100 +++ b/fsaccess/ops.c Wed Jan 17 00:52:03 2024 +0100 @@ -52,17 +52,16 @@ /* Invocation of operations. */ -enum op_results run_operation(const char *operation, int argc, char *argv[]) +enum op_results run_operation(const char *operation, int argc, char *argv[], int *exitcode) { struct operation *op; - int exitcode; for (op = &operations[0]; op->name != NULL; op++) { if (!strcmp(operation, op->name)) { - exitcode = op->fn(argc, argv); - if (exitcode) + *exitcode = op->fn(argc, argv); + if (*exitcode) return OP_FAILED; break; } diff -r fb7127ee218e -r 11c3032fffcc fsaccess/ops.h --- a/fsaccess/ops.h Mon Jan 15 23:44:56 2024 +0100 +++ b/fsaccess/ops.h Wed Jan 17 00:52:03 2024 +0100 @@ -31,7 +31,8 @@ }; int handle_op_result(const char *operation, enum op_results op_result); -enum op_results run_operation(const char *operation, int argc, char *argv[]); +enum op_results run_operation(const char *operation, int argc, char *argv[], + int *exitcode); /* Operations exposed by the program. */