blob: bd72ecf713e6b53cadc9f6edf7945dca8c95e1c4 (
plain)
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
|
#include <stdio.h>
#include <time.h>
int main(int argc, char **argv)
{
char *argv1[]={"/bin/foolshell",0};
char *env1[]={"PS1=\033[34m$\033[37m","PWD=/home/miguel","PATH=/bin","TERM=fool-term",0};
time_t ltime;
time(<ime);
printf("Current time: %s", ctime(<ime));
printf("fool-init: spawning a Fool's Shell\n");
// loop forever and spawn shells if the top-shell exits
while(1)
{
int pid=_fork();
printf("fool-init: pid: %i\n",pid);
int status;
if(pid==0)
{
_execve("/bin/foolshell",argv1,env1); // replace process with our foolshell :)
//execve("/bin/clear",argv,env); // replace process with our foolshell :)
puts("FATAL ERROR: Something terrible happened. Unable to Execute SHELL!");
while(1);// hang
}
// wait until our child process state changes (exits)
// and respawn SHELL
_wait(&status);
printf("fool-init: catched exit of process %d.\n",pid);
printf("fool-init: respawning a Fools Shell\n");
}
return 0;
}
|