Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Linux system updates executable files of running processes need to pay attention to the reasons for text file busy and what is the solution

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

Linux system updates the executable files of running processes need to pay attention to the text file busy reasons and solutions, I believe that many inexperienced people do not know what to do about this, so this paper summarizes the causes of the problem and solutions, through this article I hope you can solve this problem.

Recently, I found that many students do not know the main points of online operation to replace files. So I tidied it up again.

When replacing a running process file online (including binaries, dynamic libraries, resource files that need to be read, etc.). Cp/scp operations should be avoided. Instead, you need to use mv/rsync instead.

Reason: cp truncates the source file and writes new content. That is, the process that is opening the file can perceive the change immediately. Modifying the contents of the file is likely to cause program logic errors or even crashes. On the other hand, mv marks "delete" the old file, and then puts a new file with the same name in the past. In other words, the old file and the new file are actually two different files (inode is different), but the name is the same. The process of opening old files will not be affected. If the process uses mmap to open a file (such as loading so), if the target file is overwritten with cp and the length becomes smaller. Then reading the address of the difference (which no longer exists in the new file) will result in a SIGBUS signal. Cause the process to crash.

As for the executable itself. I am not afraid that cp will lead to collapse. Because "text file busy" will be reported when cp. Not cp at all. You should also use the mv class operation at this time. Restart the process after the replacement is complete. What is executed is the new executable.

After reading the above, have you mastered the reasons and solutions for the text file busy that the linux system needs to pay attention to when updating the executable files of the running process? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report