Giving a Child Process a Time Budget

A launcher can limit how long it waits for work. Its cancellation and cleanup behavior needs a separate contract.

Source
Anbloq
Language
English
Created
Updated
Chapters
4
Reading time
1 min
In this article4 chapters
  1. Trace a useful timeout
  2. Check any partial results
  3. Apply a budget to the waiting operation and define cleanup
  4. Test timeout and normal error separately

Trace a useful timeout

A report process expected to finish in five seconds may remain running after the caller stops waiting unless managed accordingly. Cooperative cancellation distinguishes requesting a stop from confirming it.

Check any partial results

If the process wrote an intermediate output, a timeout cannot prove whether publication occurred. Verify the intended file state and exit observations. See unknown outcomes.[1]

Apply a budget to the waiting operation and define cleanup

A batch command may be expected to finish within five seconds. If the parent stops waiting after five, the child can still be running unless the API or caller also handles termination. Record what happens to child resources and partial output. See waiting for a child.

Start child
Deadline reached with no completed result
Apply documented termination and wait behavior
Capture an explicit timeout result

Test timeout and normal error separately

A command exiting immediately with an error has a final status. A timeout describes a budget exceeded and possible remaining work. Test both with small controlled programs and ensure no unwanted background task persists.

References

  1. The Open Group, POSIX Shell Command Language ↩