mirror of
https://github.com/moparisthebest/pacman
synced 2025-03-02 10:21:49 -05:00
runscriptlet : Flush open fds before fork() to avoid cloning buffers
This is a bug I noticed 2 years ago : http://www.nabble.com/Re%3A-logging-output-crazy-to11437357.html#a11479679 I thought I fixed it with 57d77eab32c01cd7572a11f76480a3724d09c029 But the bug was still here. Reading man fork, this part caught my attention: * The child inherits copies of the parent's set of open file descriptors. Each file descriptor in the child refers to the same open file description (see open(2)) as the corresponding file descriptor in the parent. This means that the two descriptors share open file status flags, current file offset, and signal-driven I/O attributes (see the description of F_SETOWN and F_SETSIG in fcntl(2)). Since the open file descriptors are inherited, it is probably a good idea to flush them before forking. Signed-off-by: Xavier Chantry <shiningxc@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
parent
687f04ab46
commit
36863b968f
@ -511,6 +511,9 @@ int _alpm_runscriptlet(const char *root, const char *installfn,
|
||||
}
|
||||
_alpm_log(PM_LOG_DEBUG, "%s\n", cmdline);
|
||||
|
||||
/* Flush open fds before fork() to avoid cloning buffers */
|
||||
fflush(NULL);
|
||||
|
||||
/* fork- parent and child each have seperate code blocks below */
|
||||
pid = fork();
|
||||
if(pid == -1) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user