aboutsummaryrefslogtreecommitdiffstats
path: root/csci4061/092120_breakout
diff options
context:
space:
mode:
authorRossTheRoss <mstrapp@protonmail.com>2021-01-17 12:57:21 -0600
committerRossTheRoss <mstrapp@protonmail.com>2021-01-17 12:57:21 -0600
commitdde37c31a72f4773e95faf8223ef450440bdb62c (patch)
treee238837d1d2f364b95483f6281960f9483078c1a /csci4061/092120_breakout
parentIDK (diff)
downloadhomework-dde37c31a72f4773e95faf8223ef450440bdb62c.tar
homework-dde37c31a72f4773e95faf8223ef450440bdb62c.tar.gz
homework-dde37c31a72f4773e95faf8223ef450440bdb62c.tar.bz2
homework-dde37c31a72f4773e95faf8223ef450440bdb62c.tar.lz
homework-dde37c31a72f4773e95faf8223ef450440bdb62c.tar.xz
homework-dde37c31a72f4773e95faf8223ef450440bdb62c.tar.zst
homework-dde37c31a72f4773e95faf8223ef450440bdb62c.zip
get rid of that trash
Diffstat (limited to 'csci4061/092120_breakout')
-rw-r--r--csci4061/092120_breakout/main.c50
1 files changed, 0 insertions, 50 deletions
diff --git a/csci4061/092120_breakout/main.c b/csci4061/092120_breakout/main.c
deleted file mode 100644
index 8d8e08d..0000000
--- a/csci4061/092120_breakout/main.c
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
-CSci 4061 - Recitation 2 - 21st Sept 2020
-Breakout 1
-An iditoic loner's lone attempt
-*/
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/types.h>
-#include <sys/wait.h>
-#include <unistd.h>
-#include <errno.h>
-
-int main(int argc, char **argv) {
- // take 'n' from the input and convert to integer
- // hint: see cmd slide
- if (argc < 2) {
- printf("USAGE: ./main int\n");
- return -1;
- }
- int n = strtol(argv[1], NULL, 10);
- // for i in n
- // create child process
- // print pid //hint: check week 2 slides
- // call execl to print 'hello there' using 'echo' //hint: check recitation slide
- pid_t pid;
- for (int i=0; i<n; i++) {
- pid = fork();
- if (pid == 0) {
-
- } else {
-printf("%d\n", getpid());
- execl("/bin/echo", "/bin/echo", "hello", "there", NULL);
- }
- }
- // parent waits for all child processes to terminate
- for (int i=0; i<n; i++) {
- wait(NULL);
- }
- // parent create child process
- // call execv on 'ptime' executable // hint: similar to 'echo' usage in slide
- pid = fork();
- if (pid != 0) {
- char *args[] = {"./ptime", NULL};
- execv(*args, args);
- }
- // parent waits for child to complete
- waitpid(pid, NULL, 0);
- return 0;
-} \ No newline at end of file