Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

TSR Programming, Is It possible?

Is it possible to write Terminate-and-Stay Resident Programs in C under Unix / Linux environment?

Anyone help me in this regard.

Please post any material regarding the above topic to my id given as follows

kvureshkumar@rediffmail.com


Comments

  • bikibiki Member Posts: 492
    Is it possible to write Terminate-and-Stay Resident Programs in C under Unix / Linux environment?
    [green]Yes[/green]
    : Anyone help me in this regard.
    [green]Maybe...see below[/green]
    : Please post any material regarding the above topic to my id given as follows
    :
    [green]Don't visit this board just to have your questions mailed to you. Nobody wants to give out their email addresses unnecessarily...thats why boards like this exist too[/green]

    [size=2][red]

    [b]Bikram[/b][/red]
    [blue]http://www.geocities.com/nv5050[/blue]
    [red]**************************************[/red][/size]

  • fnoyanfnoyan Member Posts: 103
    Hi
    Try the code below. The code does not belong to me...

    /*
    Demonio tipo UNIX, codigo de ejemplo.
    UNIX Daemon, example code rules.
    By:
    Por:
    Oscar Medina Duarte
    is111936@mail.udlap.mx

    */

    #include
    #include
    #include
    #include

    void damncode();
    void teschingando(int);
    void setduplicate(int);

    main(){
    pid_t pid;

    signal(SIGINT,teschingando);
    signal(SIGUSR1, setduplicate);

    pid = fork();

    if (pid <0){
    printf("Forking Error : )
    ");
    exit(-1);
    }else if (pid !=0 ){
    printf("
    This is a Father 1
    ");
    }else{
    pid = fork();

    if (pid <0){
    printf("Forking error : )
    ");
    exit(-1);
    }else if (pid !=0 ){
    printf("
    This is a father 2
    ");
    }else{

    /* Poner en modo daemon */
    /* Set Daemon mode */
    setsid();
    umask(0);
    chdir("/");
    damncode(); /* Y ejecutar el daemon, run the daemon */

    }
    }

    }







    void damncode(){

    printf("Daemon :
    PID %d PPID %d
    ",getpid(),getppid());
    for(;;);
    }

    void teschingando(int signo){

    printf("Signal : %d",signo);
    exit(1);
    }

    void setduplicate(int signo){
    main();
    }





    : Is it possible to write Terminate-and-Stay Resident Programs in C under Unix / Linux environment?
    :
    : Anyone help me in this regard.
    :
    : Please post any material regarding the above topic to my id given as follows
    :
    : kvureshkumar@rediffmail.com
    :
    :
    :

Sign In or Register to comment.