コード例 #1
0
ファイル: main.c プロジェクト: Brucegx/Appstore719
pid_t
WaitForValidPidFile(void)
{
    CFAbsoluteTime patience = CFAbsoluteTimeGetCurrent() + kChildStartPidTimeout;
    
    // Poll for a child process and pidfile to be generated, until we lose patience.
    pid_t pid = -1;
    while ((pid = CheckForValidPidFile()) == -1 && (patience - CFAbsoluteTimeGetCurrent() > 0))
        sleep(1);
        
    if (verbosity >= 3)
        LogMessage("Discovered pid %d from pidfile %s\n", pid, pidFile);

    return pid;
}
コード例 #2
0
ファイル: main.c プロジェクト: cooljeanius/MacPorts-fork
/* WaitForValidPidFile: Sometimes a valid pidfile will need to be generated first before anything can be done.
 * Arguments: None.
 * Return value: The valid pidfile that was found after waiting for it.
 * Notes: Requires CoreFoundation (checked for by the MP_CHECK_FRAMEWORK_COREFOUNDATION autoconf macro in configure.ac, which comes from acinclude.m4)
 */
pid_t
WaitForValidPidFile(void)
{
    CFAbsoluteTime patience = CFAbsoluteTimeGetCurrent() + kChildStartPidTimeout;

    // Poll for a child process and pidfile to be generated, until we lose patience (literally: "patience" is a variable name).
	// TODO: polling is generally considered bad; could there be a better way to do this?
    pid_t pid = -1;
    while ((pid = CheckForValidPidFile()) == -1 && (patience - CFAbsoluteTimeGetCurrent() > 0))
        sleep(1);

    if (verbosity >= 3)
        LogMessage("Discovered pid %d from pidfile %s\n", pid, pidFile);

    return pid;
}