From 9d8cd99dfa156fa48801aa8bc7821c62d023fe80 Mon Sep 17 00:00:00 2001 From: _ov4 Date: Tue, 11 Aug 2026 10:33:39 +0000 Subject: init --- mysplit.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 mysplit.c (limited to 'mysplit.c') diff --git a/mysplit.c b/mysplit.c new file mode 100644 index 0000000..9ac016e --- /dev/null +++ b/mysplit.c @@ -0,0 +1,35 @@ +/* + * mysplit.c - Another handy routine for testing your tiny shell + * + * usage: mysplit + * Fork a child that spins for seconds in 1-second chunks. + */ +#include +#include +#include +#include +#include +#include + +int main(int argc, char **argv) +{ + int i, secs; + + if (argc != 2) { + fprintf(stderr, "Usage: %s \n", argv[0]); + exit(0); + } + secs = atoi(argv[1]); + + + if (fork() == 0) { /* child */ + for (i=0; i < secs; i++) + sleep(1); + exit(0); + } + + /* parent waits for child to terminate */ + wait(NULL); + + exit(0); +} -- cgit v1.3.1-4-g156e