子进程可以改变父进程的变量吗? [英] Can the variables of a parent process be changed by the child process?
本文介绍了子进程可以改变父进程的变量吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我知道线程共享相同的变量吗?但是流程呢?
I know that threads share the same variables? But what about processes?
推荐答案
进程有单独的内存空间.一个进程不能改变另一个进程的内存,父/子进程也不例外.子级不能更改父级的变量,父级也不能更改其子级的变量.
Processes have separate memory spaces. One process cannot change the memory of another process, and parent/child processes are no exception. A child cannot change a parent's variables, nor a parent its children's.
进程之间必须使用进程间通信 (IPC) 机制来相互通信,例如:
Processes must use inter-process communication (IPC) mechanisms to talk to each other, such as:
- 管道
- 信号
- 文件
- UNIX 套接字
- 网络套接字
- 共享内存
这篇关于子进程可以改变父进程的变量吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文