jerpelea opened a new pull request, #3798:
URL: https://github.com/apache/nuttx-apps/pull/3798
## Summary
Adds a per-service "console [<device>]" option to nxinit's init.rc
service syntax, plus two small robustness fixes uncovered while adding
it.
Services started by nxinit (e.g. plain "sh") do not open a console
device on their own, unlike nsh_main, which explicitly does so via
nsh_consolemain()/nsh_waitusbready() for USB gadget consoles
(CDC-ACM/PL2303). When a board switches its top-level init from
nsh_main to nxinit, no code path ever registers/connects a USB
console gadget, and a service that just execs a plain "sh" inherits
whatever (invalid, for a gadget console not yet opened) stdio nxinit
itself has. This was the actual root cause of a real-hardware
regression reported on esp32s3-xiao (board hangs, no USB console) —
see the companion apache/nuttx PR for the board-side fix that uses
this option.
A service declared with console [<device>] gets the given device
(CONFIG_SYSTEM_NXINIT_CONSOLE_DEV, "/dev/console" by default, if no
device is given) opened and dup'd onto its stdin, stdout and stderr via
posix_spawn_file_actions before it is spawned. This does not depend
on nsh being enabled at all — for a USB gadget console, boards are
expected to bring the gadget up themselves before any service using
"console" starts (e.g. via an exec -- sercon init.rc action, since
apps/system/cdcacm already implements exactly that and depends on
neither nxinit nor nsh either).
Two commits unrelated to the option itself, split out for review:
system/nxinit: fix missing blank line after declaration in service.c —
pre-existing nxstyle nit in option_reboot_on_failure(),
unrelated to this change but in a file this PR already touches.
system/nxinit: retry a service whose spawn failed —
init_service_refresh() ignored the return value of
init_service_start(); a service whose spawn fails stayed
SVC_RESTARTING with nothing left to arm this function's own poll
timeout, and (being a failed spawn) no SIGCHLD either to wake the
event loop some other way. If it were the only pending timer, the
loop would block indefinitely and the service would never be
attempted again. Also moves the time_started update in
init_service_start() from after a successful spawn to before the
spawn is even attempted, so a failure doesn't leave a stale timestamp
behind (which would otherwise make a repeatedly failing service look
permanently "overdue" and get retried on every unrelated wakeup,
bypassing its own restart_period).
## Impact
RELEASE
## Testing
CI
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]