VirtualBox

Changeset 3581 in kBuild


Ignore:
Timestamp:
Jan 5, 2023 12:42:11 PM (2 years ago)
Author:
bird
Message:

kmk/posixos.c: Try fix race in make_job_rfd.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kmk/posixos.c

    r3512 r3581  
    4040   If we use pselect() this will never be created and always -1.
    4141 */
    42 static int job_rfd = -1;
     42static int volatile job_rfd = -1; /* bird: added volatile to try ensure atomic update.  */
    4343
    4444/* Token written to the pipe (could be any character...)  */
     
    5252  return 0;
    5353#else
    54   EINTRLOOP (job_rfd, dup (job_fds[0]));
    55   if (job_rfd >= 0)
    56     CLOSE_ON_EXEC (job_rfd);
    57 
    58   return job_rfd;
     54  /* bird: modified to use local variable and only update job_rfd once, otherwise
     55           we're racing the signal handler clearing and closing this. */
     56  int new_job_rfd;
     57  EINTRLOOP (new_job_rfd, dup (job_fds[0]));
     58  if (new_job_rfd >= 0)
     59    CLOSE_ON_EXEC (new_job_rfd);
     60
     61  job_rfd = new_job_rfd;
     62  return new_job_rfd;
    5963#endif
    6064}
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette