Skip to content

init: clock_worker child process falls through into main() on failure #580

@jhrozek

Description

@jhrozek

When __TIMESYNC__ is enabled, main() forks a child to run clock_worker():

if (fork() == 0) {
    clock_worker();
}

If clock_worker() encounters an error (socket creation fails, bind() fails, or recv() fails), it returns. Because there is no _exit() after the call, the child process falls through and continues executing the rest of main(). This causes it to:

  1. Fork again at line 1214, creating an unintended grandchild process
  2. Attempt to execute the workload via execvp(), duplicating it
  3. Enter the waitpid() loop in the parent branch, interfering with process lifecycle management

The impact is that any transient failure in timesync setup silently causes the workload to be launched twice, which may produce difficult-to-diagnose issues ranging from port conflicts to corrupted state.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions