Forum

> > CS2D > Scripts > shell for linux (debian)
Forums overviewCS2D overview Scripts overviewLog in to reply

English shell for linux (debian)

21 replies
Page
To the start Previous 1 2 Next To the start

old Re: shell for linux (debian)

tontonEd
User Off Offline

Quote
this should work :
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
#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;		
}
1- change ./cs2d_dedicated_path (line ~= 15)
2- create new file & copy/past : newFile.c
3- compile : gcc -o main newFile.c
4- run : ./main
To the start Previous 1 2 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview