C固定变量和Linux叉 [英] C static variables and linux fork

查看:102
本文介绍了C固定变量和Linux叉的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好我创建了一个派生一个新的进程的接受套接字连接后的服务器程序。
有在程序中定义几个静态分配全局变量。我的问题是有叉后两次分配这些静态缓冲区?还是叉子仅在堆和调用堆栈复制地址空间?

Hi I created a server program that forks a new process after its accepts a socket connection. There are several statically allocated global variables defined in the program. My question is are these static buffers allocated twice after the fork? Or does the fork only duplicate address space on the heap and the call stack?

推荐答案

全部的地址空间被复制,包括所有的全局变量和程序文本。

The entire address space is duplicated, including all global variables and the program text.

这篇关于C固定变量和Linux叉的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆