From 9d8cd99dfa156fa48801aa8bc7821c62d023fe80 Mon Sep 17 00:00:00 2001 From: _ov4 Date: Tue, 11 Aug 2026 10:33:39 +0000 Subject: init --- mystop.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 mystop.c (limited to 'mystop.c') diff --git a/mystop.c b/mystop.c new file mode 100644 index 0000000..12eee5f --- /dev/null +++ b/mystop.c @@ -0,0 +1,36 @@ +/* + * mystop.c - Another handy routine for testing your tiny shell + * + * usage: mystop + * Sleeps for seconds and sends SIGTSTP to itself. + * + */ +#include +#include +#include +#include +#include +#include + +int main(int argc, char **argv) +{ + int i, secs; + pid_t pid; + + if (argc != 2) { + fprintf(stderr, "Usage: %s \n", argv[0]); + exit(0); + } + secs = atoi(argv[1]); + + for (i=0; i < secs; i++) + sleep(1); + + pid = getpid(); + + if (kill(-pid, SIGTSTP) < 0) + fprintf(stderr, "kill (tstp) error"); + + exit(0); + +} -- cgit v1.3.1-4-g156e