예제 #1
0
파일: main.c 프로젝트: WinLinKer/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 );
        }

        struct timespec timeout;

        timeout.tv_sec = 1;

        timeout.tv_nsec = 0;

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

        i++;
    }
}
예제 #2
0
파일: main.c 프로젝트: WinLinKer/alilua
static void worker_main ( int at )
{

    attach_on_exit ( on_exit_handler );

    setProcessUser ( /*user*/ NULL, /*group*/ NULL );

    setProcTitle ( "worker process", 0 );
    _process_chdir = process_chdir;

    /// 进入 loop 处理循环
    network_worker ( worker_process, process_count, at );

    exit ( 0 );
}
예제 #3
0
파일: main.c 프로젝트: 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++;
    }
}