File size: 1,100 Bytes
f329bf7
 
 
 
 
 
 
 
 
 
 
 
 
d7d19bd
 
 
 
 
 
 
 
 
 
 
 
f329bf7
 
d7d19bd
f329bf7
 
 
 
 
 
 
 
 
 
 
 
d7d19bd
f329bf7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include <stdio.h>
#include <stdlib.h>
#include <sys/wait.h>
#include <unistd.h>
#include <string.h>

#define MAX_DIGIT 10


int total_mission = 64;
int min_mission = 33;
int max_mission = 48;

#ifndef TOTAL_MISSION
#define TOTAL_MISSION total_mission
#endif

#ifndef MIN_MISSION
#define MIN_MISSION min_mission
#endif

#ifndef MAX_MISSION
#define MAX_MISSION max_mission
#endif


int main(int argc, char* argv[]) {
	for (int i = MIN_MISSION; i <= MAX_MISSION; i ++) {
		int pid = fork();
		if (pid < 0) {
			perror("fork");
		}
		if (pid == 0) {
			char batch_number[MAX_DIGIT];
			char batch_count[MAX_DIGIT];

			memset(batch_number, '\0', MAX_DIGIT * sizeof(char));
			memset(batch_count, '\0', MAX_DIGIT * sizeof(char));

			sprintf(batch_number, "%d", i);
			sprintf(batch_count, "%d", TOTAL_MISSION);

			char *cmd = "./venv/bin/python";
			char *args[] = {"./venv/bin/python", "font_ds_generate_script.py", batch_number, batch_count, NULL};

			if (execvp(cmd, args) < 0) {
				perror("execvp");
			}
		}
	}

	pid_t wpid;
	int status = 0;
	while ((wpid = wait(&status)) > 0) {}
	return 0;
}