为什么通过system()或execvp()从子进程调用cd shell命令不会工作? [英] why calling cd shell command through system() or execvp() from a child process won't work?

查看:250
本文介绍了为什么通过system()或execvp()从子进程调用cd shell命令不会工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我明白我应该使用chdir(),但我只需要一个解释,为什么通过系统或execvp()从子进程调用cd shell命令不会工作?感谢!!

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!!

推荐答案

因为 chdir 只修改当前环境处理。它不能触及父级环境。

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

另请参阅链接。triee。

See also the link posted by tripleee.

这篇关于为什么通过system()或execvp()从子进程调用cd shell命令不会工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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