1.grigory.18_test.executer 1.aleksandra.18_test.executer

--- 1.grigory.18_test.executer.fmt.c	2020-06-08 11:39:11.613114358 +0300
+++ 1.aleksandra.18_test.executer.fmt.c	2020-06-08 11:39:11.596114175 +0300
@@ -1,40 +1,44 @@
 #1 "<stdin>"
 #include <stdio.h>
-#include <stdlib.h>
 #include <unistd.h>
 #include <sys/types.h>
 #include <sys/stat.h>
-#include <sys/wait.h>
 #include <fcntl.h>
+#include <sys/wait.h>
 #include <string.h>
-int executor(char **argv) {
-    int file, size, stat;
-    char *filename = "temp";
+#include <stdlib.h>
+int executing(int argc, char *argv[]) {
+    char *filename = "dumpfile";
+    int wstatus, size, fin;
     if (fork()) {
-	wait(&stat);
-	file = open(filename, O_RDONLY);
-	size = lseek(file, 0, SEEK_END);
+	wait(&wstatus);
+	fin = open(filename, O_RDONLY);
+	size = lseek(fin, 0, SEEK_END);
 	printf("%d\n", size);
     } else {
 	close(1);
-	file = open(filename, O_CREAT | O_TRUNC | O_WRONLY, 0644);
+	fin = open(filename, O_CREAT | O_TRUNC | O_WRONLY, 0644);
 	execvp(argv[0], &argv[0]);
-	close(file);
+	close(fin);
     }
     return 0;
 }
-int argParse(char *s) {
-    char **argv = malloc(strlen(s));
-    int i = 0;
-    char *token;
-    while ((token = strtok_r(s, " ", &s)))
-	argv[i++] = token;
-    executor(argv);
+int parse(char *s) {
+    char **argv, *token, *delim = " ";
+    int i, argc = 0;
+    argv = malloc(strlen(s));
+    for (i = 0;; i++, s = NULL) {
+	if ((token = strtok(s, delim)) == NULL)
+	    break;
+	argv[i] = token;
+	argc += 1;
+    }
+    executing(argc, argv);
     free(argv);
     return 0;
 }
-int main(int argc, char **argv) {
+int main(int argc, char *argv[]) {
     for (int i = 1; i < argc; i++)
-	argParse(argv[i]);
+	parse(argv[i]);
     return 0;
 }