Ajmin: That's what I'm talking about, you're wrong. Forum
Scripts
shell for linux (debian)
shell for linux (debian)
21 replies
Ajmin: That's what I'm talking about, you're wrong. 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
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
#include <signal.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
static int flag = 0;
void handler() {
	//set flag to 1
	flag = 1;
}
int main(){
int pid = fork();
int pidfils;
if( pid == 0){
	// Child process will return 0 from fork()
	pidfils = getpid();
	//get child pid
execv("./cs2d_dedicated_path",NULL);
	//run cs2d
exit(0);
}else{
// Parent process will return a non-zero value from fork()
	while(1){
	signal(SIGCHLD,handler);
	//call handler when child died
	if(flag == 1){
		wait();
		//wait his son
		flag = 0;
		main();
		//recusiv func
	 }	
}
}
return 0;		
}
2- create new file & copy/past : newFile.c
3- compile : gcc -o main newFile.c
4- run : ./main



Offline