diff --git a/.idea/.name b/.idea/.name new file mode 100644 index 0000000000000000000000000000000000000000..1c145519827f0ddcd080cc0362cc53c27ccfb9ff --- /dev/null +++ b/.idea/.name @@ -0,0 +1 @@ +simple_chatting2 \ No newline at end of file diff --git a/cmake-build-debug/CMakeFiles/control.dir/CXX.includecache b/cmake-build-debug/CMakeFiles/control.dir/CXX.includecache new file mode 100644 index 0000000000000000000000000000000000000000..8bd02c7efe057fe297570b38dc98c0d0cf201816 --- /dev/null +++ b/cmake-build-debug/CMakeFiles/control.dir/CXX.includecache @@ -0,0 +1,42 @@ +#IncludeRegexLine: ^[ ]*[#%][ ]*(include|import)[ ]*[<"]([^">]+)([">]) + +#IncludeRegexScan: ^.*$ + +#IncludeRegexComplain: ^$ + +#IncludeRegexTransform: + +/home/centos/code/ojt-simple-chatting/function/define.h + +/home/centos/code/ojt-simple-chatting/function/ipc_module.cpp +ipc_module.h +/home/centos/code/ojt-simple-chatting/function/ipc_module.h + +/home/centos/code/ojt-simple-chatting/function/ipc_module.h +define.h +/home/centos/code/ojt-simple-chatting/function/define.h +sys/ipc.h +- +sys/shm.h +- +sys/msg.h +- +cstring +- +iostream +- +vector +- +map +- + +/home/centos/code/ojt-simple-chatting/src/control.cpp +iostream +- +cstring +- +cstdio +- +unistd.h +- + diff --git a/cmake-build-debug/CMakeFiles/control.dir/depend.internal b/cmake-build-debug/CMakeFiles/control.dir/depend.internal new file mode 100644 index 0000000000000000000000000000000000000000..19a780da8207d577abf830fead478d0be46c16b5 --- /dev/null +++ b/cmake-build-debug/CMakeFiles/control.dir/depend.internal @@ -0,0 +1,9 @@ +# CMAKE generated file: DO NOT EDIT! +# Generated by "Unix Makefiles" Generator, CMake Version 3.19 + +CMakeFiles/control.dir/function/ipc_module.cpp.o + /home/centos/code/ojt-simple-chatting/function/define.h + /home/centos/code/ojt-simple-chatting/function/ipc_module.cpp + /home/centos/code/ojt-simple-chatting/function/ipc_module.h +CMakeFiles/control.dir/src/control.cpp.o + /home/centos/code/ojt-simple-chatting/src/control.cpp diff --git a/cmake-build-debug/CMakeFiles/control.dir/depend.make b/cmake-build-debug/CMakeFiles/control.dir/depend.make index 3c0d190203e3df26905b2515d60318265be5ea70..f3a1c4d6949ef0fa9a38c3aa4173186e1375353c 100644 --- a/cmake-build-debug/CMakeFiles/control.dir/depend.make +++ b/cmake-build-debug/CMakeFiles/control.dir/depend.make @@ -1,2 +1,9 @@ -# Empty dependencies file for control. -# This may be replaced when dependencies are built. +# CMAKE generated file: DO NOT EDIT! +# Generated by "Unix Makefiles" Generator, CMake Version 3.19 + +CMakeFiles/control.dir/function/ipc_module.cpp.o: ../function/define.h +CMakeFiles/control.dir/function/ipc_module.cpp.o: ../function/ipc_module.cpp +CMakeFiles/control.dir/function/ipc_module.cpp.o: ../function/ipc_module.h + +CMakeFiles/control.dir/src/control.cpp.o: ../src/control.cpp + diff --git a/cmake-build-debug/CMakeFiles/control.dir/function/ipc_module.cpp.o b/cmake-build-debug/CMakeFiles/control.dir/function/ipc_module.cpp.o new file mode 100644 index 0000000000000000000000000000000000000000..452652a16f18cd1f8b6e62a2087d8557a0f84cae Binary files /dev/null and b/cmake-build-debug/CMakeFiles/control.dir/function/ipc_module.cpp.o differ diff --git a/cmake-build-debug/CMakeFiles/control.dir/src/control.cpp.o b/cmake-build-debug/CMakeFiles/control.dir/src/control.cpp.o new file mode 100644 index 0000000000000000000000000000000000000000..97df0e20964350ce9a8b5b3ab5077cc2fbbfdd96 Binary files /dev/null and b/cmake-build-debug/CMakeFiles/control.dir/src/control.cpp.o differ diff --git a/cmake-build-debug/CMakeFiles/server.dir/CXX.includecache b/cmake-build-debug/CMakeFiles/server.dir/CXX.includecache new file mode 100644 index 0000000000000000000000000000000000000000..9e6b08424a924f5d1e7fc9159b07b045c1292d74 --- /dev/null +++ b/cmake-build-debug/CMakeFiles/server.dir/CXX.includecache @@ -0,0 +1,38 @@ +#IncludeRegexLine: ^[ ]*[#%][ ]*(include|import)[ ]*[<"]([^">]+)([">]) + +#IncludeRegexScan: ^.*$ + +#IncludeRegexComplain: ^$ + +#IncludeRegexTransform: + +/home/centos/code/ojt-simple-chatting/function/define.h + +/home/centos/code/ojt-simple-chatting/function/ipc_module.h +define.h +/home/centos/code/ojt-simple-chatting/function/define.h +sys/ipc.h +- +sys/shm.h +- +sys/msg.h +- +cstring +- +iostream +- +vector +- +map +- + +/home/centos/code/ojt-simple-chatting/src/server.cpp +csignal +- +iostream +- +unistd.h +- +../function/ipc_module.h +/home/centos/code/ojt-simple-chatting/function/ipc_module.h + diff --git a/cmake-build-debug/CMakeFiles/server.dir/depend.internal b/cmake-build-debug/CMakeFiles/server.dir/depend.internal new file mode 100644 index 0000000000000000000000000000000000000000..6a1453d87f54000b85aecad1785377f12d5d4ac7 --- /dev/null +++ b/cmake-build-debug/CMakeFiles/server.dir/depend.internal @@ -0,0 +1,11 @@ +# CMAKE generated file: DO NOT EDIT! +# Generated by "Unix Makefiles" Generator, CMake Version 3.19 + +CMakeFiles/server.dir/function/ipc_module.cpp.o + /home/centos/code/ojt-simple-chatting/function/define.h + /home/centos/code/ojt-simple-chatting/function/ipc_module.cpp + /home/centos/code/ojt-simple-chatting/function/ipc_module.h +CMakeFiles/server.dir/src/server.cpp.o + /home/centos/code/ojt-simple-chatting/function/define.h + /home/centos/code/ojt-simple-chatting/function/ipc_module.h + /home/centos/code/ojt-simple-chatting/src/server.cpp diff --git a/cmake-build-debug/CMakeFiles/server.dir/depend.make b/cmake-build-debug/CMakeFiles/server.dir/depend.make index 519938d8e9d53b8b4d97c940f71d2cb223e3f420..860cfaec71c1c2f502836b797700276b4df55aee 100644 --- a/cmake-build-debug/CMakeFiles/server.dir/depend.make +++ b/cmake-build-debug/CMakeFiles/server.dir/depend.make @@ -1,2 +1,11 @@ -# Empty dependencies file for server. -# This may be replaced when dependencies are built. +# CMAKE generated file: DO NOT EDIT! +# Generated by "Unix Makefiles" Generator, CMake Version 3.19 + +CMakeFiles/server.dir/function/ipc_module.cpp.o: ../function/define.h +CMakeFiles/server.dir/function/ipc_module.cpp.o: ../function/ipc_module.cpp +CMakeFiles/server.dir/function/ipc_module.cpp.o: ../function/ipc_module.h + +CMakeFiles/server.dir/src/server.cpp.o: ../function/define.h +CMakeFiles/server.dir/src/server.cpp.o: ../function/ipc_module.h +CMakeFiles/server.dir/src/server.cpp.o: ../src/server.cpp + diff --git a/cmake-build-debug/CMakeFiles/server.dir/function/ipc_module.cpp.o b/cmake-build-debug/CMakeFiles/server.dir/function/ipc_module.cpp.o new file mode 100644 index 0000000000000000000000000000000000000000..452652a16f18cd1f8b6e62a2087d8557a0f84cae Binary files /dev/null and b/cmake-build-debug/CMakeFiles/server.dir/function/ipc_module.cpp.o differ diff --git a/cmake-build-debug/CMakeFiles/server.dir/src/server.cpp.o b/cmake-build-debug/CMakeFiles/server.dir/src/server.cpp.o new file mode 100644 index 0000000000000000000000000000000000000000..03f455dbf4fb51372936c991ae67a1c4666f7e9e Binary files /dev/null and b/cmake-build-debug/CMakeFiles/server.dir/src/server.cpp.o differ diff --git a/cmake-build-debug/CMakeFiles/test.dir/CXX.includecache b/cmake-build-debug/CMakeFiles/test.dir/CXX.includecache new file mode 100644 index 0000000000000000000000000000000000000000..c5872c4a06edd614c1bbe9b07d4b98df053697d1 --- /dev/null +++ b/cmake-build-debug/CMakeFiles/test.dir/CXX.includecache @@ -0,0 +1,18 @@ +#IncludeRegexLine: ^[ ]*[#%][ ]*(include|import)[ ]*[<"]([^">]+)([">]) + +#IncludeRegexScan: ^.*$ + +#IncludeRegexComplain: ^$ + +#IncludeRegexTransform: + +/home/centos/code/ojt-simple-chatting/src/test.cpp +map +- +iostream +- +sys/msg.h +- +unistd.h +- + diff --git a/cmake-build-debug/CMakeFiles/test.dir/depend.internal b/cmake-build-debug/CMakeFiles/test.dir/depend.internal new file mode 100644 index 0000000000000000000000000000000000000000..064cabbc8af741a034f70d4fe5cb6c5aa23b3658 --- /dev/null +++ b/cmake-build-debug/CMakeFiles/test.dir/depend.internal @@ -0,0 +1,5 @@ +# CMAKE generated file: DO NOT EDIT! +# Generated by "Unix Makefiles" Generator, CMake Version 3.19 + +CMakeFiles/test.dir/src/test.cpp.o + /home/centos/code/ojt-simple-chatting/src/test.cpp diff --git a/cmake-build-debug/CMakeFiles/test.dir/depend.make b/cmake-build-debug/CMakeFiles/test.dir/depend.make index 3f2657bc32075a5b386ecd96e52b6bc1ca185e45..9c2221aa468eff5c2074c10b084d3a4d3bcda9a2 100644 --- a/cmake-build-debug/CMakeFiles/test.dir/depend.make +++ b/cmake-build-debug/CMakeFiles/test.dir/depend.make @@ -1,2 +1,5 @@ -# Empty dependencies file for test. -# This may be replaced when dependencies are built. +# CMAKE generated file: DO NOT EDIT! +# Generated by "Unix Makefiles" Generator, CMake Version 3.19 + +CMakeFiles/test.dir/src/test.cpp.o: ../src/test.cpp + diff --git a/cmake-build-debug/CMakeFiles/test.dir/src/test.cpp.o b/cmake-build-debug/CMakeFiles/test.dir/src/test.cpp.o new file mode 100644 index 0000000000000000000000000000000000000000..0358cae401e5ffc32e1d9a6c0e062d699847d523 Binary files /dev/null and b/cmake-build-debug/CMakeFiles/test.dir/src/test.cpp.o differ diff --git a/cmake-build-debug/Testing/Temporary/LastTest.log b/cmake-build-debug/Testing/Temporary/LastTest.log index 7e377a48ab8149036c564559ebe34966b64cc317..5e1fe9f16edebd15cb43059a257f73f286e3fd5c 100644 --- a/cmake-build-debug/Testing/Temporary/LastTest.log +++ b/cmake-build-debug/Testing/Temporary/LastTest.log @@ -1,3 +1,3 @@ -Start testing: Jan 29 17:41 KST +Start testing: Jan 29 18:40 KST ---------------------------------------------------------- -End testing: Jan 29 17:41 KST +End testing: Jan 29 18:40 KST diff --git a/cmake-build-debug/control b/cmake-build-debug/control index 3ab9684a421a6e9d16773600f848638068fe5aa9..6d1f3491daf6d72b924e94cef5b5651c6fb81f3b 100755 Binary files a/cmake-build-debug/control and b/cmake-build-debug/control differ diff --git a/cmake-build-debug/server b/cmake-build-debug/server index 0e14fda101cff9853d00909b023de230a0109ce7..020b21384f6db02fcaf801a5227da6a668ed7950 100755 Binary files a/cmake-build-debug/server and b/cmake-build-debug/server differ diff --git a/cmake-build-debug/test b/cmake-build-debug/test index 7626700d42fec98636e9c9d2ece648cdfac5b1b1..6de9eadd04c33ea79d422f54fb80874f41ef6e13 100755 Binary files a/cmake-build-debug/test and b/cmake-build-debug/test differ diff --git a/function/ipc_module.h b/function/ipc_module.h index 64a5cddd6fe6425e812bd978274006255106d7bc..e398750ec298ca45e588e64c11a2962d62027668 100644 --- a/function/ipc_module.h +++ b/function/ipc_module.h @@ -32,7 +32,7 @@ public: //shared memory class SHM { public: - struct ProcessInfo{ + struct ClientInfo{ int snd_pid; //parent int rcv_pid; //child std::string name; @@ -42,7 +42,7 @@ public: int server_pid; int server_status; int msq_id; - std::map user; //key = snd_pid + std::map user; //key = client name }; static int Init(int server_pid); //return shared memory id diff --git a/src/control.cpp b/src/control.cpp index 7f6b4fc028c1e879803977eb158220f2a704fcd7..c029ac261bf23972a91207d72fb99888d2a30813 100644 --- a/src/control.cpp +++ b/src/control.cpp @@ -1,6 +1,9 @@ #include #include +#include +#include void HowToUse(); // if invalid argument +void ShowStatus(); int main(int argc, char *argv[]) { @@ -12,6 +15,8 @@ int main(int argc, char *argv[]) { } else if(argc==3){ if(strcmp(argv[1], "start")==0&&strcmp(argv[2], "server")==0){ //start server + char *dummy_arg[]={nullptr}; + execv("./server",dummy_arg); return 0; } else if(strcmp(argv[1], "stop")==0&&strcmp(argv[2], "server")==0){ //stop server diff --git a/src/server.cpp b/src/server.cpp index 91d976f5d679a7c2e3f32c249cf7826e75f12aaa..8d24dbb8b6d8bf9de78b3a25a6bb8d83374c2105 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -12,26 +12,26 @@ int main() { } else { std::cout<<"! Chatting server start failed !"< #include #include +#include class SHM { public: struct ProcessDir{ @@ -12,6 +13,23 @@ public: }; int main() { +} +int test3(){ + pid_t pid = fork(); + if(pid){ + //p +// for(int i=0;i<100000000;i++){ +// printf("pasdfasdfasdf\n"); +// } + return 0; + } else { + //c + sleep(1); + for(int i=0;i<100000000;i++){ + printf("pasdfasdfasdf\n"); + } + return 0; + } } int test2(){ int id1 = msgget(909090,0);