int main(int argc, char **argv) { //printf("fool-init: spawning a Fool's Shell\n"); // loop forever and spawn shells if the top-shell exits while(1) { int pid=fork(); int status; if(pid==0) { char *argv[]={"/bin/foolshell",0}; char *env[]={"PS1=$","PWD=/home/miguel","PATH=/bin","TERM=xterm",0}; execve("/bin/foolshell",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; }