Lab6
This commit is contained in:
Generated
-2
@@ -1,2 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module classpath="CMake" type="CPP_MODULE" version="4" />
|
||||
Generated
+7
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Encoding">
|
||||
<file url="file://$PROJECT_DIR$/cmake-build-debug/agent.pid" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/cmake-build-debug/agent.txt" charset="UTF-8" />
|
||||
</component>
|
||||
</project>
|
||||
+2
-1
@@ -8,4 +8,5 @@ SET(GCC_COVERAGE_COMPILE_FLAGS "-pthread")
|
||||
|
||||
|
||||
add_executable(OS
|
||||
Lab5/ex4.c)
|
||||
Lab6/agent.c
|
||||
Lab6/agent.c)
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int main() {
|
||||
/*
|
||||
On startup, the agent program creates the file
|
||||
/var/run/agent.pid and writes its PID into the file. It then reads
|
||||
the contents of a file called text.txt, prints it on the console and
|
||||
finally sleeps indefinitely
|
||||
*/
|
||||
FILE *file = fopen("text.txt", "w");
|
||||
FILE *filePid = fopen("agent.txt", "w");
|
||||
fputc(getpid(), filePid);
|
||||
fclose(filePid);
|
||||
fclose(file);
|
||||
char pid_str[10];
|
||||
fgets(pid_str, sizeof(pid_str), file);
|
||||
fclose(file);
|
||||
|
||||
FILE *text_file = fopen("text.txt", "r");
|
||||
if (text_file == NULL) {
|
||||
printf("Error opening text.txt\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
char c;
|
||||
while ((c = fgetc(text_file))!= EOF)
|
||||
printf("%c", c);
|
||||
|
||||
fclose(text_file);
|
||||
|
||||
printf("\nSleeping indefinitely...\n");
|
||||
while (1)
|
||||
sleep(1);
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
//
|
||||
// Created by emil on 01.10.2024.
|
||||
//
|
||||
@@ -0,0 +1,28 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int main() {
|
||||
/*
|
||||
* Write a C program that prints “Hello world!” an infinite number
|
||||
of times.
|
||||
Run the program, and kill it by pressing (Ctrl+C). Which signal
|
||||
did the process receive? Can we handle it? Can the process ignore
|
||||
the signal?
|
||||
Run the program, and kill it by pressing (Ctrl+\). Which signal
|
||||
did the process receive? Can we handle it? Can the process ignore
|
||||
the signal? In Ubuntu, set core dump size via ulimit -c
|
||||
unlimited. The core dump file is in /var/lib/apport/coredump/.
|
||||
Check the log file /var/log/apport.log for core dump file name.
|
||||
Run the program in the background (&) and redirect stdout to a
|
||||
file output.txt, kill the process by sending the signal “SIGTERM”
|
||||
via “kill -s SIGTERM pid ” command. Can we handle the
|
||||
signal? Can the process ignore the signal? Send the signal
|
||||
“SIGKILL” if the program does not terminate politely.
|
||||
30 / 58
|
||||
*/
|
||||
|
||||
|
||||
while (1)
|
||||
printf("Hello world!\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
Binary file not shown.
@@ -2,10 +2,32 @@
|
||||
1 59 1727194503928197251 CMakeFiles/OS.dir/Lab5/ex2-3.c.o 3ac11e55017104db
|
||||
1 69 1727194450713397978 CMakeFiles/OS.dir/Lab5/ex2.c.o aaf388779ce03a6e
|
||||
1 54 1727193068898104463 CMakeFiles/OS.dir/Lab5/ex1.c.o 87ce1149fbd620b
|
||||
1 53 1727797041565849223 CMakeFiles/OS.dir/Lab6/example1.c.o 6be6e05f0bf8623a
|
||||
1 81 1727191541519747212 CMakeFiles/OS.dir/Lab4/ex1.c.o fdfe48b329a854c3
|
||||
1 50 1726585076082163985 CMakeFiles/OS.dir/main.c.o 597d2975f9346988
|
||||
1 31 1727195105069329767 build.ninja 102e4adb4b6285fe
|
||||
59 91 1727194503984862096 OS 7e7768c095bc6d8a
|
||||
1 36 1727195105069329767 build.ninja 102e4adb4b6285fe
|
||||
1 32 1727798122261377224 build.ninja 102e4adb4b6285fe
|
||||
54 100 1727797041615835169 OS 87096d11c57d1daa
|
||||
0 63 1727195105082663185 CMakeFiles/OS.dir/Lab5/ex4.c.o 60daafb2653af2a5
|
||||
63 96 1727195105142663566 OS 5ac1e89d9f8b3dbb
|
||||
2 36 1727796978102865786 CMakeFiles/OS.dir/Lab6/controller.c.o e3d69d5ce71c382d
|
||||
1 77 1727798135878055008 CMakeFiles/OS.dir/Lab6/agent.c.o f04cc81de1844813
|
||||
77 120 1727798135954721726 OS d21dc05418483373
|
||||
0 51 1727798170544732035 CMakeFiles/OS.dir/Lab6/agent.c.o f04cc81de1844813
|
||||
51 95 1727798170594732034 OS d21dc05418483373
|
||||
1 58 1727798268007998305 CMakeFiles/OS.dir/Lab6/agent.c.o f04cc81de1844813
|
||||
58 95 1727798268064664903 OS d21dc05418483373
|
||||
1 60 1727798299751289808 CMakeFiles/OS.dir/Lab6/agent.c.o f04cc81de1844813
|
||||
61 103 1727798299811289723 OS d21dc05418483373
|
||||
1 58 1727798320507925611 CMakeFiles/OS.dir/Lab6/agent.c.o f04cc81de1844813
|
||||
58 99 1727798320564592190 OS d21dc05418483373
|
||||
1 56 1727798362207857032 CMakeFiles/OS.dir/Lab6/agent.c.o f04cc81de1844813
|
||||
56 95 1727798362264523600 OS d21dc05418483373
|
||||
1 57 1727798440361045239 CMakeFiles/OS.dir/Lab6/agent.c.o f04cc81de1844813
|
||||
58 94 1727798440417711794 OS d21dc05418483373
|
||||
1 58 1727798718513790447 CMakeFiles/OS.dir/Lab6/agent.c.o f04cc81de1844813
|
||||
58 93 1727798718570456989 OS d21dc05418483373
|
||||
1 59 1727798905596710944 CMakeFiles/OS.dir/Lab6/agent.c.o f04cc81de1844813
|
||||
59 93 1727798905656710811 OS d21dc05418483373
|
||||
1 57 1727798934466646963 CMakeFiles/OS.dir/Lab6/agent.c.o f04cc81de1844813
|
||||
57 94 1727798934523313503 OS d21dc05418483373
|
||||
1 58 1727798985353200771 CMakeFiles/OS.dir/Lab6/agent.c.o f04cc81de1844813
|
||||
59 93 1727798985409867312 OS d21dc05418483373
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
Start testing: Sep 24 19:25 MSK
|
||||
Start testing: Oct 01 20:02 MSK
|
||||
----------------------------------------------------------
|
||||
End testing: Sep 24 19:25 MSK
|
||||
End testing: Oct 01 20:02 MSK
|
||||
|
||||
@@ -49,11 +49,11 @@ cmake_ninja_workdir = /home/emil/CLionProjects/OS/cmake-build-debug/
|
||||
|
||||
build cmake_object_order_depends_target_OS: phony || .
|
||||
|
||||
build CMakeFiles/OS.dir/Lab5/ex4.c.o: C_COMPILER__OS_unscanned_Debug /home/emil/CLionProjects/OS/Lab5/ex4.c || cmake_object_order_depends_target_OS
|
||||
DEP_FILE = CMakeFiles/OS.dir/Lab5/ex4.c.o.d
|
||||
build CMakeFiles/OS.dir/Lab6/agent.c.o: C_COMPILER__OS_unscanned_Debug /home/emil/CLionProjects/OS/Lab6/agent.c || cmake_object_order_depends_target_OS
|
||||
DEP_FILE = CMakeFiles/OS.dir/Lab6/agent.c.o.d
|
||||
FLAGS = -g -std=gnu11 -fdiagnostics-color=always
|
||||
OBJECT_DIR = CMakeFiles/OS.dir
|
||||
OBJECT_FILE_DIR = CMakeFiles/OS.dir/Lab5
|
||||
OBJECT_FILE_DIR = CMakeFiles/OS.dir/Lab6
|
||||
|
||||
|
||||
# =============================================================================
|
||||
@@ -63,7 +63,7 @@ build CMakeFiles/OS.dir/Lab5/ex4.c.o: C_COMPILER__OS_unscanned_Debug /home/emil/
|
||||
#############################################
|
||||
# Link the executable OS
|
||||
|
||||
build OS: C_EXECUTABLE_LINKER__OS_Debug CMakeFiles/OS.dir/Lab5/ex4.c.o
|
||||
build OS: C_EXECUTABLE_LINKER__OS_Debug CMakeFiles/OS.dir/Lab6/agent.c.o
|
||||
FLAGS = -g
|
||||
OBJECT_DIR = CMakeFiles/OS.dir
|
||||
POST_BUILD = :
|
||||
|
||||
Reference in New Issue
Block a user