mirror of
https://github.com/genodelabs/genode.git
synced 2025-04-07 19:34:56 +00:00
libc: update O_APPEND fds on joined child
The fds in O_APPEND state may have changed by the child. The local seek state needs to be valid/current for the next to be forked child, which seek state is set by File_descriptor_allocator::generate_info(). Issue #3991
This commit is contained in:
parent
9bfd812a88
commit
5fa91c573b
@ -113,6 +113,11 @@ namespace Libc {
|
||||
*/
|
||||
File_descriptor *any_cloexec_libc_fd();
|
||||
|
||||
/**
|
||||
* Update seek state of file descriptor with append flag set.
|
||||
*/
|
||||
void update_append_libc_fds();
|
||||
|
||||
/**
|
||||
* Return file-descriptor ID of any open file, or -1 if no file is
|
||||
* open
|
||||
|
@ -127,6 +127,17 @@ File_descriptor *File_descriptor_allocator::any_cloexec_libc_fd()
|
||||
}
|
||||
|
||||
|
||||
void File_descriptor_allocator::update_append_libc_fds()
|
||||
{
|
||||
Mutex::Guard guard(_mutex);
|
||||
|
||||
_id_space.for_each<File_descriptor>([&] (File_descriptor &fd) {
|
||||
if (fd.flags & O_APPEND)
|
||||
fd.plugin->lseek(&fd, 0, SEEK_END);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
int File_descriptor_allocator::any_open_fd()
|
||||
{
|
||||
Mutex::Guard guard(_mutex);
|
||||
|
@ -721,6 +721,8 @@ extern "C" pid_t __sys_wait4(pid_t pid, int *status, int options, rusage *rusage
|
||||
return Fn::INCOMPLETE;
|
||||
});
|
||||
|
||||
file_descriptor_allocator()->update_append_libc_fds();
|
||||
|
||||
/*
|
||||
* The libc expects status information in bits 0..6 and the exit value
|
||||
* in bits 8..15 (according to 'wait.h').
|
||||
|
Loading…
x
Reference in New Issue
Block a user