亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

  免費(fèi)注冊 查看新帖 |

Chinaunix

  平臺(tái) 論壇 博客 文庫
最近訪問板塊 發(fā)新帖
查看: 2716 | 回復(fù): 3
打印 上一主題 下一主題

子進(jìn)程退出父進(jìn)程也跟著退出了。 [復(fù)制鏈接]

論壇徽章:
0
跳轉(zhuǎn)到指定樓層
1 [收藏(0)] [報(bào)告]
發(fā)表于 2008-11-13 15:23 |只看該作者 |倒序?yàn)g覽
我在父進(jìn)程中vfork了一個(gè)子進(jìn)程,在子進(jìn)程中運(yùn)行telnet。結(jié)果當(dāng)我退出telnet時(shí),父進(jìn)程也跟著退出了。

我用waitpgid得到的退出狀態(tài)是256.

請問這是為什么,這個(gè)問題已經(jīng)困擾好幾天了。

論壇徽章:
4
2015年辭舊歲徽章
日期:2015-03-03 16:54:152015年迎新春徽章
日期:2015-03-04 09:56:11IT運(yùn)維版塊每日發(fā)帖之星
日期:2016-08-11 06:20:00IT運(yùn)維版塊每日發(fā)帖之星
日期:2016-08-15 06:20:00
2 [報(bào)告]
發(fā)表于 2008-11-13 15:35 |只看該作者

回復(fù) #1 312-pirl0 的帖子

父進(jìn)程是一個(gè)無限循環(huán)嗎?
能否把代碼貼出來呢?

論壇徽章:
0
3 [報(bào)告]
發(fā)表于 2008-11-13 15:57 |只看該作者
父進(jìn)程是個(gè)類似命令行的東西,是無限循環(huán)的。

    string final_command = _command;
    list<string>::const_iterator iter;
    for (iter = _argument_list.begin(); iter != _argument_list.end(); ++iter) {
        final_command += " ";
        final_command += *iter;
    }

    //
    // Save the current execution ID, and set the new execution ID
    //
    _exec_id.save_current_exec_id();
    if (_exec_id.set_effective_exec_id(error_msg) != XORP_OK) {
        XLOG_ERROR("Failed to set effective execution ID: %s",
                   error_msg.c_str());
        _exec_id.restore_saved_exec_id(error_msg);
        return (XORP_ERROR);
    }

#ifndef HOST_OS_WINDOWS
    signal(SIGCHLD, child_handler);
#endif

    //
    // Temporary block the child signals
    //
    block_child_signals();

    //
    // Run the command
    //
    _pid = popen2(_command, _argument_list, _stdout_stream, _stderr_stream,
                  redirect_stderr_to_stdout());
    if (_stdout_stream == NULL) {
        XLOG_ERROR("Failed to execute command \"%s\"", final_command.c_str());
        cleanup();
        _exec_id.restore_saved_exec_id(error_msg);
        return (XORP_ERROR);
    }
    // Insert the new process to the map of processes
    XLOG_ASSERT(pid2command.find(_pid) == pid2command.end());
    pid2command[_pid] = this;

    _is_running = true;

    //
    // Restore the saved execution ID
    //
    _exec_id.restore_saved_exec_id(error_msg);

    //
    // Unblock the child signals that were blocked earlier
    //
    unblock_child_signals();

    return (XORP_OK);

static void
child_handler(int signo)
{
    XLOG_ASSERT(signo == SIGCHLD);

    do {
        pid_t pid = 0;
        int wait_status = 0;
        map<pid_t, RunCommandBase *>::iterator iter;

        pid = waitpid(-1, &wait_status, WUNTRACED | WNOHANG);
        debug_msg("pid=%d, wait status=%d\n", XORP_INT_CAST(pid), wait_status);
        if (pid <= 0)
            return;        // XXX: no more child processes

        XLOG_ASSERT(pid > 0);
        popen2_mark_as_closed(pid, wait_status);
        iter = pid2command.find(pid);
        if (iter == pid2command.end()) {
            // XXX: we don't know anything about the exited process
            continue;
        }

        RunCommandBase* run_command = iter->second;
        run_command->wait_status_changed(wait_status);
    } while (true);
}

這是主要的代碼。

論壇徽章:
4
2015年辭舊歲徽章
日期:2015-03-03 16:54:152015年迎新春徽章
日期:2015-03-04 09:56:11IT運(yùn)維版塊每日發(fā)帖之星
日期:2016-08-11 06:20:00IT運(yùn)維版塊每日發(fā)帖之星
日期:2016-08-15 06:20:00
4 [報(bào)告]
發(fā)表于 2008-11-13 18:08 |只看該作者
父進(jìn)程異常退出,有沒有core dump呢?
如果生成了core文件,可以使用gdb進(jìn)行調(diào)試,這樣定位問題就方便了。
您需要登錄后才可以回帖 登錄 | 注冊

本版積分規(guī)則 發(fā)表回復(fù)

  

北京盛拓優(yōu)訊信息技術(shù)有限公司. 版權(quán)所有 京ICP備16024965號(hào)-6 北京市公安局海淀分局網(wǎng)監(jiān)中心備案編號(hào):11010802020122 niuxiaotong@pcpop.com 17352615567
未成年舉報(bào)專區(qū)
中國互聯(lián)網(wǎng)協(xié)會(huì)會(huì)員  聯(lián)系我們:huangweiwei@itpub.net
感謝所有關(guān)心和支持過ChinaUnix的朋友們 轉(zhuǎn)載本站內(nèi)容請注明原作者名及出處

清除 Cookies - ChinaUnix - Archiver - WAP - TOP