コマンドを分岐し、最小限のBusyboxシェルで非同期的に実行するためにこの特別なデバイスが必要な理由は疑問に思います。
BusyBox v1.30.1 (Debian 1:1.30.1-4) built-in shell (ash)
Enter 'help' for a list of built-in commands.
/bin/sh: can't access tty; job control turned off
/ #
/ # echo Hello && sleep 2s && echo World &
/bin/sh: / # can't open '/dev/null': No such file or directory
/ #
/ # mknod /dev/null c 1 3 && chmod 666 /dev/null
/ # echo Hello && sleep 2s && echo World &
/ # Hello
World
/ #
答え1
~から実装するbusyboxのシェル:
/*
* Fork off a subshell. If we are doing job control, give the subshell its
* own process group. Jp is a job structure that the job is to be added to.
* N is the command that will be evaluated by the child. Both jp and n may
* be NULL. The mode parameter can be one of the following:
* FORK_FG - Fork off a foreground process.
* FORK_BG - Fork off a background process.
* FORK_NOJOB - Like FORK_FG, but don't give the process its own
* process group even if job control is on.
*
* When job control is turned off, background processes have their standard
* input redirected to /dev/null (except for the second and later processes
* in a pipeline).
*
* Called with interrupts off.
*/
「入力が/ dev / nullにリダイレクトされました」に注意してください。サブシェルの標準入力がリダイレクトされるため/dev/null
(ジョブ制御がオフになってアクセス/dev/tty
できないため、リダイレクトされる予定です)、デバイスファイルにアクセスできないとエラーが発生します。