Skip to content
Snippets Groups Projects
Unverified Commit d9e69f72 authored by Alexander Turenko's avatar Alexander Turenko
Browse files

popen: fix 'may be clobbered' compiler warning


I guess a compiler assumes that the code inside vfork may use the stack
slot that corresponds the variable and so clobber it. The recent commit
07a07b3c ('popen: decouple logger fd
from stderr') adds read from this variable after vfork() in the parent
process.

The warning is produced on RelWithDebInfo build with LTO enabled on GCC
9.2.0 (locally) and on GCC 8.3.0 (in CI).

Part of #4031

Acked-by: default avatarCyrill Gorcunov <gorcunov@gmail.com>
parent 7c923503
No related branches found
No related tags found
No related merge requests found
......@@ -784,10 +784,11 @@ struct popen_handle *
popen_new(struct popen_opts *opts)
{
/*
* Without volatile compiler claims that
* handle might be clobbered from vfork.
* Without volatile compiler claims that those
* variables might be clobbered from vfork.
*/
struct popen_handle * volatile handle;
int volatile log_fd = -1;
int pfd[POPEN_FLAG_FD_STDEND_BIT][2] = {
{-1, -1}, {-1, -1}, {-1, -1},
......@@ -853,7 +854,6 @@ popen_new(struct popen_opts *opts)
* reached a file descriptor limit.
*/
int old_log_fd = log_get_fd();
int log_fd = -1;
if (old_log_fd >= 0) {
log_fd = dup_not_std_streams(old_log_fd);
if (log_fd < 0)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment