why calling cd shell command through system() or execvp() from a child process won't work?

微笑、不失礼 提交于 2019-12-11 02:58:43

问题


I understand that i am supposed to use chdir() but I just need an explanation as to why calling cd shell command through system or execvp() from a child process would not work? Thanks!!


回答1:


Because chdir only modifies the environment of the current process. It can't touch the environment of the parent.

See also the link posted by tripleee.



来源:https://stackoverflow.com/questions/7120493/why-calling-cd-shell-command-through-system-or-execvp-from-a-child-process-w

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!