networkRestart should fork/exec instead of system(cmd)
|Status:||New||Start date:||12 Jan 2021|
|Target version:||PiBox - 2.0 - Harkonnen|
|Severity:||01 - Critical|
The system() call is synchronous which means we wait for it to finish. A better way to handle this is to fork the request and have a reaper thread deal with it so piboxd is not stuck waiting for the restart to complete. This may require a general purpose child launcher/reaper mechanism for piboxd. It's possible the existing threads could handle it, however, using internal message formats such as MT_INTERNAL_xxx (i.e. not public ones used by piboxMsg) that are dropped by the msgProcessor if they're received from outside clients.
Additionally the call should be a popen() instead of system() to capture errors for logging.
The retry loop assumes the caller asks for a specific interface. The message format for MT_NET/MA_RESTART should allow for specifying the interface name, no name if any interface can be allowed to satisfy network availability or NONE if we don't care if the network comes back up. These can be added as subtypes:
- MS_NONE: no payload
- MS_ANY: no payload
- MS_IF: the payload is the IF name