util/jobutil.cc
/// Test for the presence of the pidfile named by prog.
/// Return 0 if no live pid found, or the running pid if found.
///
Test for the presence of the pidfile named by prog.
Return 0 if no live pid found, or the running pid if found.
Test for the presence of the pidfile named by prog . Return 0 if no live pid found or the running pid if found .
pid_t is_running(const char *prog)
{
    pid_t pid=0;
    fs::path pidpath;
    get_pid_path(prog,pidpath);
    if (fs::exists(pidpath)) {
        if (read_pid( pidpath, pid )) {
            bool livep =  is_live_pid( pid );
            std::cerr << "PID file " << pidpath << " with PID=" << pid
                      << (livep ? " and is alive" : " but is dead") << std::endl;
            return (livep ? pid : 0);
        } else {
            std::cerr << "Failed to read a live pid from "
                      << pidpath << std::endl;
            return 0;
        }
    }
    std::cerr << "PID file " << pidpath << " does not exist." << std::endl;
    return 0;
}
pid_t is_running ( const char * prog ) { pid_t pid = 0 ; fs :: path pidpath ; get_pid_path ( prog , pidpath ) ; if ( fs :: exists ( pidpath ) ) { if ( read_pid ( pidpath , pid ) ) { bool livep = is_live_pid ( pid ) ; std :: cerr << " " << pidpath << " " << pid << ( livep ? " " : " " ) << std :: endl ; return ( livep ? pid : 0 ) ; } else { std :: cerr << " " << pidpath << std :: endl ; return 0 ; } } std :: cerr << " " << pidpath << " " << std :: endl ; return 0 ; }
Test for the presence of the pidfile named by prog.
Test for the presence of the pidfile named by prog .