Note textfilebus when updating executable files of running processes in linux

Source: Internet
Author: User
This article mainly introduces the cause and solution of textfilebusy, which should be paid attention to when updating executable files of running processes in linux, for more information about how to replace files online. So I sorted it out again.

Online Replacement of a running process file (including binary, dynamic library, resource files to be read ). Cp/scp operations should be avoided. However, mv/rsync should be used as an alternative.

Cause: cp truncates the source file and writes it to new content. That is to say, the process that is opening this file can immediately perceive the changes. Modifying the file content may cause program logic errors or even crashes. While mv marks "delete" the old file, and then adds a new file with the same name. That is to say, the old and new files are actually two different files (different inode), but the names are the same. The process of opening the old file will not be affected. If the process uses mmap to open a file (such as loading so), if the target file is overwritten by cp and the length becomes smaller. When the address of the difference is read (the new file does not actually exist), it will cause the SIGBUS signal. Crash the process.

As for the executable file itself. It is not afraid of cp causing crash .. Because "text file busy" is reported during cp ". No cp at all. In this case, mv operations should also be used. Restart the process after replacement. The new executable file is executed.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.