paul@308 | 1 | /* |
paul@308 | 2 | * A test of executing code in a new task. |
paul@308 | 3 | * |
paul@513 | 4 | * Copyright (C) 2022, 2023 Paul Boddie <paul@boddie.org.uk> |
paul@308 | 5 | * |
paul@308 | 6 | * This program is free software; you can redistribute it and/or |
paul@308 | 7 | * modify it under the terms of the GNU General Public License as |
paul@308 | 8 | * published by the Free Software Foundation; either version 2 of |
paul@308 | 9 | * the License, or (at your option) any later version. |
paul@308 | 10 | * |
paul@308 | 11 | * This program is distributed in the hope that it will be useful, |
paul@308 | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
paul@308 | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
paul@308 | 14 | * GNU General Public License for more details. |
paul@308 | 15 | * |
paul@308 | 16 | * You should have received a copy of the GNU General Public License |
paul@308 | 17 | * along with this program; if not, write to the Free Software |
paul@308 | 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, |
paul@308 | 19 | * Boston, MA 02110-1301, USA |
paul@308 | 20 | */ |
paul@308 | 21 | |
paul@308 | 22 | #include <stdio.h> |
paul@584 | 23 | #include <string.h> |
paul@584 | 24 | |
paul@584 | 25 | /* NOTE: For inclusion in the C library. */ |
paul@584 | 26 | |
paul@584 | 27 | #include <fsclient/client.h> |
paul@584 | 28 | #include <systypes/env.h> |
paul@584 | 29 | #include <systypes/fcntl.h> |
paul@308 | 30 | |
paul@308 | 31 | |
paul@308 | 32 | |
paul@308 | 33 | int main(int argc, char *argv[]) |
paul@308 | 34 | { |
paul@525 | 35 | int i; |
paul@318 | 36 | |
paul@584 | 37 | /* NOTE: For inclusion in the C library. */ |
paul@584 | 38 | |
paul@584 | 39 | file_t *output = client_get_stream(ENV_OUTPUT_STREAM_NAME, O_WRONLY); |
paul@584 | 40 | |
paul@584 | 41 | /* Write the arguments to the output stream. */ |
paul@584 | 42 | |
paul@584 | 43 | char buffer[32]; |
paul@584 | 44 | |
paul@318 | 45 | for (i = 0; i < argc; i++) |
paul@584 | 46 | { |
paul@584 | 47 | sprintf(buffer, "Arg #%d: ", i); |
paul@584 | 48 | client_write(output, buffer, strlen(buffer)); |
paul@584 | 49 | client_write(output, argv[i], strlen(argv[i])); |
paul@584 | 50 | client_write(output, "\n", 1); |
paul@584 | 51 | } |
paul@318 | 52 | |
paul@584 | 53 | client_write(output, "Terminating.\n", 13); |
paul@589 | 54 | |
paul@589 | 55 | /* NOTE: For inclusion in the C library. */ |
paul@589 | 56 | |
paul@584 | 57 | client_flush(output); |
paul@589 | 58 | |
paul@589 | 59 | /* NOTE: To test process completion, the output stream is left open. */ |
paul@589 | 60 | |
paul@308 | 61 | return 0; |
paul@308 | 62 | } |
paul@308 | 63 | |
paul@308 | 64 | /* vim: tabstop=2 expandtab shiftwidth=2 |
paul@308 | 65 | */ |