Exemplo n.º 1
0
static void master_main()
{
    setProcTitle ( "master process", 1 );

    _process_chdir = process_chdir;

    if ( !new_thread ( process_checker ) ) {
        perror ( "process checker thread error!" );
        exit ( -1 );
    }

    int i = 0;

    while ( 1 ) {
        if ( checkProcessForExit() ) {
            kill ( 0, SIGTERM ); /// 关闭子进程
            on_master_exit_handler ( 0, NULL, NULL );
            exit ( 0 );
        }

        struct timespec timeout;

        timeout.tv_sec = 1;

        timeout.tv_nsec = 0;

        while ( nanosleep ( &timeout, &timeout ) && errno == EINTR );

        i++;
    }
}
Exemplo n.º 2
0
Arquivo: main.c Projeto: no2key/alilua
static void master_main()
{
    setProcTitle ( "master process", 1 );

    _process_chdir = process_chdir;

    if ( !new_thread ( process_checker ) ) {
        perror ( "process checker thread error!" );
        exit ( -1 );
    }

    int i = 0;

    while ( 1 ) {
        if ( checkProcessForExit() ) {
            kill ( 0, SIGTERM ); /// 关闭子进程
            on_master_exit_handler ( 0, NULL, NULL );
            exit ( 0 );
        }

        sleep ( 1 );
        i++;
    }
}