News for hackers. Stuff that matters.
Re:How does `cd` work? by ChristianBundy on Thursday March 01, 2018 @02:31PM (#16495324)
cd is part of your shell, so trying to invoke cd from another program would be like opening a new browser tab from another program. It's an internal feature without an outward-facing API.
Re:How does `cd` work? by qubex on Thursday March 01, 2018 @02:36PM (#16495382)
There's no reason why one shouldn't be able to invoke the chdir system call and implement the same behaviour.
Re:How does `cd` work? by chc on Thursday March 01, 2018 @02:59PM (#16495624)
Well, I mean, a program can call chdir() and it works exactly as it's supposed to, but it only affects that program, not a different program.
Re:How does `cd` work? by gowld on Thursday March 01, 2018 @02:48PM (#16495493)
Allowing any process to arbitrarily modify the state of another process would be a disaster for stability and security.
Re:How does `cd` work? by colejohnson66 on Thursday March 01, 2018 @09:19PM (#16498422)
Isn’t that what a debugger does?
Re:How does `cd` work? by Someone on Friday March 02, 2018 @03:47AM (#16500023)
Yes, and it is a disaster for stability and security. The designers of dtrace worked hard on the stability part. See, for example, the section on DIF safety in https://www.cs.princeton.edu/courses/archive/fall04/cos518/p....