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

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

Chinaunix

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

請教一下,有_exit和沒有的區(qū)別是什么? [復(fù)制鏈接]

論壇徽章:
0
跳轉(zhuǎn)到指定樓層
1 [收藏(0)] [報(bào)告]
發(fā)表于 2007-08-17 15:02 |只看該作者 |倒序?yàn)g覽
#include "def.h"
int glob = 10;
void test_vfork(void);
int
main(void)
{
    char* buf = malloc(sizeof(char)*16);
    sprintf(buf,"in main glob = %d\n",glob);
    write(STDOUT_FILENO,buf,strlen(buf));
    test_vfork();
    sprintf(buf,"in main glob = %d\n",glob);
    write(STDOUT_FILENO,buf,strlen(buf));
    exit(0);
}
void
test_vfork(void)
{
    pid_t pid;
    if((pid = vfork()) < 0)
        errmsg("vfork error\n");
    else if( pid == 0 )
    {
        glob++;
        printf("in vfork glob = %d\n",glob);
//      _exit(0);
    }
    if(waitpid(pid,NULL,0) != pid)
        errmsg("waitpid error\n");
}

程序的運(yùn)行流程是怎樣的?
在我機(jī)器上如果有_exit(0),我預(yù)料一樣,沒有_exit結(jié)果如下:
in main glob = 10
in vfork glob = 11
waitpid error
error number is :No child processes
in main glob = 11
in vfork glob = 12
waitpid error
error number is :No child processes
Killed
是什么原因呢?
謝謝指點(diǎn)!

論壇徽章:
0
2 [報(bào)告]
發(fā)表于 2007-08-17 15:22 |只看該作者
_exit(0) is not flush stdin, stdout, etc.....

論壇徽章:
0
3 [報(bào)告]
發(fā)表于 2007-08-17 15:32 |只看該作者
_exit對上面那個程序的影響是什么?謝謝

論壇徽章:
0
4 [報(bào)告]
發(fā)表于 2007-08-17 16:47 |只看該作者
明白了,是vfork的原因。

論壇徽章:
95
程序設(shè)計(jì)版塊每日發(fā)帖之星
日期:2015-09-05 06:20:00程序設(shè)計(jì)版塊每日發(fā)帖之星
日期:2015-09-17 06:20:00程序設(shè)計(jì)版塊每日發(fā)帖之星
日期:2015-09-18 06:20:002015亞冠之阿爾艾因
日期:2015-09-18 10:35:08月度論壇發(fā)貼之星
日期:2015-09-30 22:25:002015亞冠之阿爾沙巴布
日期:2015-10-03 08:57:39程序設(shè)計(jì)版塊每日發(fā)帖之星
日期:2015-10-05 06:20:00每日論壇發(fā)貼之星
日期:2015-10-05 06:20:002015年亞冠紀(jì)念徽章
日期:2015-10-06 10:06:482015亞冠之塔什干棉農(nóng)
日期:2015-10-19 19:43:35程序設(shè)計(jì)版塊每日發(fā)帖之星
日期:2015-10-21 06:20:00每日論壇發(fā)貼之星
日期:2015-09-14 06:20:00
5 [報(bào)告]
發(fā)表于 2007-08-17 17:58 |只看該作者
為嘛老有人研究這個 vfork?

論壇徽章:
0
6 [報(bào)告]
發(fā)表于 2007-08-17 22:27 |只看該作者
就是,就是,都沒人用vfork
您需要登錄后才可以回帖 登錄 | 注冊

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

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP