LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 12-22-2006, 02:46 PM   #1
mcamember
LQ Newbie
 
Registered: Dec 2006
Location: Lowell, Mass. U.S.A.
Distribution: xandros
Posts: 14

Rep: Reputation: 0
Making syscall chdir permanent when app ends


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.
;----------------

Thanks in advance.
 
Old 12-22-2006, 03:20 PM   #2
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536

Rep: Reputation: 111Reputation: 111
Quote:
Originally Posted by mcamember
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.

The way around it would be something like:
  1. Fork an new shell from you program.
  2. Kill the parent process of you program.
  3. Have your program exit.
 
Old 12-22-2006, 03:55 PM   #3
mcamember
LQ Newbie
 
Registered: Dec 2006
Location: Lowell, Mass. U.S.A.
Distribution: xandros
Posts: 14

Original Poster
Rep: Reputation: 0
Thanks Hko. Now, at least, I won't waste any more time searching for something which doesn't exist.
 
Old 12-22-2006, 04:18 PM   #4
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
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.
 
Old 12-22-2006, 07:03 PM   #5
mcamember
LQ Newbie
 
Registered: Dec 2006
Location: Lowell, Mass. U.S.A.
Distribution: xandros
Posts: 14

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by jlliagre
which one ?
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.

Thanks very much for your time jlliagre.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Making Ndiswrapper Permanent faref Slackware 6 05-29-2006 02:18 PM
making chmod permanent Beckerjr Linux - General 5 05-11-2005 12:08 PM
making a default gateway permanent csu19032 Linux - Networking 1 07-01-2004 02:28 PM
Making Changes Permanent T-u-N-i-X Linux - General 1 09-01-2003 05:47 AM
Making SMBMOUNT Permanent unclebyron Linux - General 2 01-31-2002 05:24 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:44 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration