diff --git a/Assignment1/.idea/aws.xml b/Assignment1/.idea/aws.xml new file mode 100644 index 0000000..1356208 --- /dev/null +++ b/Assignment1/.idea/aws.xml @@ -0,0 +1,15 @@ + + + + + + + + \ No newline at end of file diff --git a/Assignment2/.idea/.gitignore b/Assignment2/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/Assignment2/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/Assignment2/.idea/Assignment2.iml b/Assignment2/.idea/Assignment2.iml new file mode 100644 index 0000000..f08604b --- /dev/null +++ b/Assignment2/.idea/Assignment2.iml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/Assignment2/.idea/aws.xml b/Assignment2/.idea/aws.xml new file mode 100644 index 0000000..b63b642 --- /dev/null +++ b/Assignment2/.idea/aws.xml @@ -0,0 +1,11 @@ + + + + + + \ No newline at end of file diff --git a/Assignment2/.idea/misc.xml b/Assignment2/.idea/misc.xml new file mode 100644 index 0000000..79b3c94 --- /dev/null +++ b/Assignment2/.idea/misc.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/Assignment2/.idea/modules.xml b/Assignment2/.idea/modules.xml new file mode 100644 index 0000000..c955c07 --- /dev/null +++ b/Assignment2/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/Assignment2/.idea/vcs.xml b/Assignment2/.idea/vcs.xml new file mode 100644 index 0000000..6c0b863 --- /dev/null +++ b/Assignment2/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Assignment2/CMakeLists.txt b/Assignment2/CMakeLists.txt new file mode 100644 index 0000000..e9c561d --- /dev/null +++ b/Assignment2/CMakeLists.txt @@ -0,0 +1,6 @@ +cmake_minimum_required(VERSION 3.22) +project(Assignment2 C) + +set(CMAKE_C_STANDARD 99) + +add_executable(Assignment2 main.c) diff --git a/Assignment2/documentation/Assignment2-v1.pdf b/Assignment2/documentation/Assignment2-v1.pdf new file mode 100644 index 0000000..abaed60 Binary files /dev/null and b/Assignment2/documentation/Assignment2-v1.pdf differ diff --git a/Assignment2/documentation/sample_execution.txt b/Assignment2/documentation/sample_execution.txt new file mode 100644 index 0000000..1331596 --- /dev/null +++ b/Assignment2/documentation/sample_execution.txt @@ -0,0 +1,47 @@ +(870665) Please input your shell command: +onechild +(870665)Hello, I am a parent process +(870666)Hello, I am a child process +(870665) Please input your shell command: +addnumbers +(870665)Please input number, (0) to terminate +1 +(870665)Read 1 +(870665)Please input number, (0) to terminate +(870667)The subtotal is: 1 +2 +(870665)Read 2 +(870665)Please input number, (0) to terminate +(870667)The subtotal is: 3 +3 +(870665)Read 3 +(870665)Please input number, (0) to terminate +(870667)The subtotal is: 6 +4 +(870665)Read 4 +(870665)Please input number, (0) to terminate +(870667)The subtotal is: 10 +0 +(870665)Read 0 +(870667)The subtotal is: 10 +(870665)The sum is 10 +(870665) Please input your shell command: +exec +(870665) Please input exec subcommand +ls +; +a.out sample_run_1.txt solution.c +(870665) Please input your shell command: +processtree +Please input the integer +3 +(870665)The value is 0 +(870671)The value is 4 +(870672)The value is 2 +(870676)The value is 3 +(870674)The value is 1 +(870673)The value is 6 +(870675)The value is 5 +(870677)The value is 7 +(870665) Please input your shell command: +stop \ No newline at end of file diff --git a/Assignment2/documentation/sample_execution_2.txt b/Assignment2/documentation/sample_execution_2.txt new file mode 100644 index 0000000..ef2ed3e --- /dev/null +++ b/Assignment2/documentation/sample_execution_2.txt @@ -0,0 +1,77 @@ +(870697) Please input your shell command: +onechild +(870697)Hello, I am a parent process +(870698)Hello, I am a child process +(870697) Please input your shell command: +onechild +(870697)Hello, I am a parent process +(870699)Hello, I am a child process +(870697) Please input your shell command: +addnumbers +(870697)Please input number, (0) to terminate +3 +(870697)Read 3 +(870697)Please input number, (0) to terminate +(870700)The subtotal is: 3 +5 +(870697)Read 5 +(870697)Please input number, (0) to terminate +(870700)The subtotal is: 8 +7 +(870697)Read 7 +(870697)Please input number, (0) to terminate +(870700)The subtotal is: 15 +0 +(870697)Read 0 +(870700)The subtotal is: 15 +(870697)The sum is 15 +(870697) Please input your shell command: +exec +(870697) Please input exec subcommand +ls +-al +; +total 40 +drwxr-xr-x 2 hidden fcsgrad 61 Sep 21 23:40 . +drwxr-xr-x 5 hidden fcsgrad 61 Sep 21 11:41 .. +-rwxr-xr-x 1 hidden fcsgrad 26824 Sep 21 23:40 a.out +-rw-r--r-- 1 hidden fcsgrad 1093 Sep 21 23:40 sample_run_1.txt +-rw-r--r-- 1 hidden fcsgrad 5503 Sep 21 23:39 solution.c +(870697) Please input your shell command: +processtree +Please input the integer +5 +(870697)The value is 0 +(870711)The value is 1 +(870708)The value is 2 +(870704)The value is 16 +(870706)The value is 4 +(870709)The value is 20 +(870713)The value is 18 +(870705)The value is 8 +(870715)The value is 10 +(870714)The value is 6 +(870710)The value is 12 +(870707)The value is 24 +(870712)The value is 28 +(870697) Please input your shell command: +(870718)The value is 3 +(870719)The value is 17 +(870720)The value is 5 +(870722)The value is 21 +(870723)The value is 19 +(870716)The value is 22 +(870725)The value is 9 +(870730)The value is 29 +(870727)The value is 11 +(870726)The value is 7 +(870721)The value is 26 +(870728)The value is 13 +(870731)The value is 23 +(870732)The value is 27 +(870729)The value is 25 +(870717)The value is 14 +(870724)The value is 30 +(870734)The value is 15 +(870733)The value is 31 +stop \ No newline at end of file diff --git a/Assignment2/main.c b/Assignment2/main.c new file mode 100644 index 0000000..3d3dac5 --- /dev/null +++ b/Assignment2/main.c @@ -0,0 +1,25 @@ +#include +#include +#include +#include +#include + +int main() { + bool is_looping = true; + // Listen loop + while (is_looping) { + char input[5][100]; + char buffer[500]; + //Print prompt + printf("[%d]> ", getpid()); + if (fgets(buffer, 500, stdin) == NULL) { + break; + } + //split buffer on spaces into input array + sscanf(buffer, "%s %s %s %s %s", input[0], input[1], input[2], input[3], input[4]); + + if (strcmp(input[0], "stop") == 0) { + is_looping = false; + } + } +}