I (sometimes) cant write my program file when a copy of it is running
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
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 (sometimes) cant write my program file when a copy of it is running
Can anyone answer this?
If I write a small program and run it, and while it is running, I try to rebuild (or in any way modify the program file), on Linux, I am (sometimes) not allowed to write to the file. Why?
In general, you cannot write to a file when it is in use. I would assume that includes a file which is a program. I don't think this is memory management--I think it is the filesystem.
Tell us more about the program--what it does, what language, etc.---and what exactly happens when you try to do something.
Actually it is question in an operating system course I am taking. We are currently studying memory management. That is why I know the answer has to do with memory management. I have search the text and internet and have not found any info that touches on this. I don't have access to Linux source as of this moment so I figure I'd put the question out the people with Linux experience.
Thank you for acknowledging that this is homework...
But now I am really confused as to what the question is. It now appears you are asking something purely hypothetical. If the question in fact relates to not being able to write to a file that is in use, I can't see how that is a memory management issue.
The question is not hypothetical as the instructor showed an example of it in class.
I think it has to do with the fact that when you change a program and recompile you change the virtual address space of the executable image. Since the text segment (shareable in Linux) is already in physical memory and being used by the copies already running, if the new version were to be run, it would be run with the old text segment. Something along those lines although I dont know, the reason for the question.
My take is that you do not understand the question. That being the case, how can we help with the answer?
You talk about compiling and running. When you run a binary (compiled program) it loads itself into memory**. When you quit, it frees the memory---the next time you run it, it could easily go somewhere else. In this context, what do you mean by the "text segment"?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.