ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I can get syscall chdir (eax=12 / int 0x80) to work correctly but I'd like the directory to remain changed when the app ends. Is there a syscall equivalent to "set current directory" ?
I've read jilliagre's post on the unique nature of chdir but hope
I don't need to get involved with the parent shell.
This is the applicable section of jilliagre's post:
;----------------
. . . in the old system chdir was an ordinary command; it adjusted the current directory of the (unique) process attached to the terminal. Under the new system, the chdir command correctly changed the current directory of the process created to execute it, but this process promptly terminated and had no effect whatsoever on its parent shell! It was necessary to make chdir a special command, executed internally within the shell. It turns out that several command-like functions have the same property, for example login.
;----------------
I can get syscall chdir (eax=12 / int 0x80) to work correctly but I'd like the directory to remain changed when the app ends. Is there a syscall equivalent to "set current directory"
Sorry, but this is not really possible this way under UN*X-like operating systems.
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789
Rep:
Quote:
Originally Posted by mcamember
I can get syscall chdir to work correctly but I'd like the directory
which one ?
Quote:
to remain changed when the app ends.
After an application ends, it has no more a current directory so I assume you mean the parent process one.
Each process has its own "current directory".
Assuming you find a way to have the parent's current directory "inherited" from its dying child, that would generate a big mess as daemons / process leaders see their current directory more or less randomly changed during their own lifetime.
The destination directory. If chdir moved from /home to /home/.mozilla while the application was processing I wanted the command prompt to remain in /home/.mozilla after the application terminated.
I wanted it to act the same as if cd home/.mozilla were issued from the command prompt.
But the application is a trivial utility and certainly not worth
endangering the stability of the o.s.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.