lab2 improved
diff --git a/Child.cpp b/Child.cpp
index 69558db..89d914a 100644
--- a/Child.cpp
+++ b/Child.cpp
@@ -1,41 +1,16 @@
-#ifdef _MSC_VER
+#include "Child.h"
 
-#define _CRT_SECURE_NO_WARNINGS
-#include <cstdlib>
-#include <windows.h>
 
-#else
-
-#include <unistd.h>
-#include <stdio.h>
-#include <cstring>
-#include <sys/types.h>
-#include <signal.h>
-
-#endif
-
-#include <string>
-#include <fstream>
-#include <ctime>
-#include <cstdlib>
-#include <iostream>
-using namespace std;
-
-#define FILE_NAME "log.log"
-#define LOG_DEBUG_LEVEL 2
-#define LOG_ERROR_LEVEL 1
-#define LOG_FATAL_LEVEL 0
-int log_level = 2;
-
-void setLevel()
+void setLevel(int log_level)
 {
+
+	time_t seconds = time(NULL);
+	tm* timeinfo = localtime(&seconds);
+	fstream file(FILE_NAME, ios::app);
 	switch (log_level)
 	{
 	case LOG_DEBUG_LEVEL:
 	{
-		time_t seconds = time(NULL);
-		tm* timeinfo = localtime(&seconds);
-		fstream file(FILE_NAME, ios::app);
 		file << asctime(timeinfo) << "some_debug_info" << endl;
 		file << asctime(timeinfo) << "Error: index out of range." << endl;
 		file << asctime(timeinfo) << "Error: could not find file." << endl;
@@ -49,9 +24,6 @@
 	}
 	case LOG_ERROR_LEVEL:
 	{
-		time_t seconds = time(NULL);
-		tm* timeinfo = localtime(&seconds);
-		fstream file(FILE_NAME, ios::app);
 		file << asctime(timeinfo) << "Error: could not find file." << endl;
 		file << asctime(timeinfo) << "Fatal_error: processes must be closed." << endl;
 		file.close();
@@ -61,9 +33,6 @@
 	}
 	case LOG_FATAL_LEVEL:
 	{
-		time_t seconds = time(NULL);
-		tm* timeinfo = localtime(&seconds);
-		fstream file(FILE_NAME, ios::app);
 		file << asctime(timeinfo) << "Fatal_error: processes must be closed." << endl;
 		file.close();
 		cout << "Fatal_error: processes must be closed." << endl;
@@ -131,6 +100,7 @@
 	char buff[3];
 	buff[0] = argv[0][0];
 	buff[2] = '\0';
+	int log_level = 2;
 
 	buff[1] = UP_EVENT;
 	if (!(up_event = OpenEventA(EVENT_ALL_ACCESS | EVENT_MODIFY_STATE, TRUE, buff)))
@@ -182,7 +152,7 @@
 		check = WaitForSingleObject(access_event, INFINITY);
 		if (check == WAIT_OBJECT_0) 
 		{
-			setLevel();
+			setLevel(log_level);
 			SetEvent(access_event);
 		}
 		Sleep(4000);
diff --git a/Child.h b/Child.h
new file mode 100644
index 0000000..17e9f3a
--- /dev/null
+++ b/Child.h
@@ -0,0 +1,27 @@
+#ifdef _MSC_VER
+
+#define _CRT_SECURE_NO_WARNINGS
+#include <cstdlib>
+#include <windows.h>
+
+#else
+
+#include <unistd.h>
+#include <stdio.h>
+#include <cstring>
+#include <sys/types.h>
+#include <signal.h>
+
+#endif
+
+#include <string>
+#include <fstream>
+#include <ctime>
+#include <cstdlib>
+#include <iostream>
+using namespace std;
+
+#define FILE_NAME "log.log"
+#define LOG_DEBUG_LEVEL 2
+#define LOG_ERROR_LEVEL 1
+#define LOG_FATAL_LEVEL 0
\ No newline at end of file
diff --git a/parent.h b/parent.h
new file mode 100644
index 0000000..54366b4
--- /dev/null
+++ b/parent.h
@@ -0,0 +1,48 @@
+#ifdef _MSC_VER
+
+#define _CRT_SECURE_NO_WARNINGS
+#include <windows.h>
+
+#else
+
+#include <unistd.h>
+#include <sys/types.h>
+#include <semaphore.h>
+#include <signal.h>
+#include <cstring>
+#include <sys/wait.h>
+
+#endif
+
+#include <iostream>
+#include <stdio.h>
+#include <string>
+using namespace std;
+
+#ifdef _MSC_VER
+
+#define UP_EVENT 'U'
+#define DOWN_EVENT 'D'
+#define EXIT_EVENT 'E'
+#define ACCESS_EVENT "A"
+#define PATH "..\\Debug\\labka2_spo_child_lin.exe"
+
+#endif
+
+#define PROCESSCOUNT 4
+
+#ifdef _MSC_VER
+STARTUPINFOA si[PROCESSCOUNT];
+PROCESS_INFORMATION pi[PROCESSCOUNT];
+HANDLE upEvent[PROCESSCOUNT], downEvent[PROCESSCOUNT], exitEvent[PROCESSCOUNT], accessEvent;
+
+#else
+
+#define PATH "child"
+int pid[PROCESSCOUNT];
+bool fl;
+void synchandler(int p){
+	fl = false;
+}
+
+#endif
\ No newline at end of file