Skip to contentSkip to conversation

package/eudev: S10udevd: wait for udevd before triggering events

PATCH Applied Dario Binacchi 3 participants 9 messages Nov 26 – Dec 4

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 package/eudev: S10udevd: wait for udevd before triggering events

start-stop-daemon starts udevd in the background and returns before udevd listens to kernel events. The coldplug events generated right after by "udevadm trigger" may then get lost, so that no module is loaded at boot.

Starting network: Waiting for interface eth0 to appear............... timeout!

Wait until udevd answers on its control socket before triggering the events. The udevadm control command of eudev has no --ping option, so use --start-exec-queue, which has no effect on a daemon whose queue is already running.

While at it, return right away when udevd fails to start, as there is no point in triggering events then.

Fixes 41258a81948fddfa7fc8ac06b69d77fa051b744d ("package/eudev: refactor init script and rename it to S10udevd")

---
Changes in v2:
- Return right away when udevd fails to start and move the wait loop out of the if statement.
- Use '[ "$i" -lt 50 ] || break' to leave the loop.
- Explain in the commit message why --start-exec-queue is used.

v1: https://lore.kernel.org/buildroot/[email protected]

 package/eudev/S10udevd | 9 +++++++++
 1 file changed, 9 insertions(+)
package/eudev/S10udevd +9 -0
index 8bb8f6eb3a01..8eb764f65215 100644
@@ -37,7 +37,16 @@ start() {
 		echo "OK"
 	else
 		echo "FAIL"
+		return "$status"
 	fi
+	# start-stop-daemon returns before udevd listens to kernel events.
+	# Wait for it, or the events triggered below may get lost.
+	i=0
+	while ! udevadm control --start-exec-queue 2>/dev/null; do
+		i=$((i + 1))
+		[ "$i" -lt 50 ] || break
+		sleep 0.1
+	done
 	udevadm trigger --type=subsystems --action=add
 	udevadm trigger --type=devices --action=add
 	udevadm settle --timeout=$SETTLE_TIMEOUT || echo "udevadm settle failed"
Signature · 6 lines
2.43.0

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#1 lore raw

Am 26.11.26 um 20:26 schrieb Dario Binacchi:

Quoted 12 lines

start-stop-daemon starts udevd in the background and returns before udevd listens to kernel events. The coldplug events generated right after by "udevadm trigger" may then get lost, so that no module is loaded at boot.

Starting network: Waiting for interface eth0 to appear............... timeout!

Wait until udevd answers on its control socket before triggering the events. The udevadm control command of eudev has no --ping option, so use --start-exec-queue, which has no effect on a daemon whose queue is already running.

Quoted 5 lines

While at it, return right away when udevd fails to start, as there is no point in triggering events then.

Fixes 41258a81948fddfa7fc8ac06b69d77fa051b744d ("package/eudev: refactor init script and rename it to S10udevd")

Applied to master, thank you!

Quoted 23 lines

---
Changes in v2:
- Return right away when udevd fails to start and move the wait loop out of the if statement.
- Use '[ "$i" -lt 50 ] || break' to leave the loop.
- Explain in the commit message why --start-exec-queue is used.

v1: https://lore.kernel.org/buildroot/[email protected]

  package/eudev/S10udevd | 9 +++++++++
  1 file changed, 9 insertions(+)
package/eudev/S10udevd +2 -0
index 8bb8f6eb3a01..8eb764f65215 100644
@@ -37,7 +37,16 @@ start() {
  		echo "OK"
  	else
  		echo "FAIL"
+		return "$status"
  	fi
+	# start-stop-daemon returns before udevd listens to kernel events.

package/eudev/S10udevd start() { · line 52

Quoted 10 lines
package/eudev/S10udevd +7 -0
+	# Wait for it, or the events triggered below may get lost.
+	i=0
+	while ! udevadm control --start-exec-queue 2>/dev/null; do
+		i=$((i + 1))
+		[ "$i" -lt 50 ] || break
+		sleep 0.1
+	done
  	udevadm trigger --type=subsystems --action=add
  	udevadm trigger --type=devices --action=add
  	udevadm settle --timeout=$SETTLE_TIMEOUT || echo "udevadm settle failed"

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

#2 lore raw
In reply to Dario Binacchi
Quoted 14 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Dario" == Dario Binacchi <[email protected]> writes:

start-stop-daemon starts udevd in the background and returns before udevd listens to kernel events. The coldplug events generated right after by "udevadm trigger" may then get lost, so that no module is loaded at boot.

Starting network: Waiting for interface eth0 to appear............... timeout!

Wait until udevd answers on its control socket before triggering the events. The udevadm control command of eudev has no --ping option, so use --start-exec-queue, which has no effect on a daemon whose queue is already running.

Quoted 4 lines

While at it, return right away when udevd fails to start, as there is no point in triggering events then.

Fixes 41258a81948fddfa7fc8ac06b69d77fa051b744d ("package/eudev: refactor init script and rename it to S10udevd")

Sorry, I know this is already committed - But if the bug was introduced by the move to backgrounding with start-stop-daemon, wouldn't it be simpler to just drop the --background argument to start-stop-daemon and instead ask udevd to background itself with -d like we did before?

Signature · 5 lines
Bye, Peter Korsgaard
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#3 lore raw

Am 27.11.26 um 09:44 schrieb Peter Korsgaard:

Quoted 17 lines
Quoted 16 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Dario" == Dario Binacchi <[email protected]> writes:

start-stop-daemon starts udevd in the background and returns before udevd listens to kernel events. The coldplug events generated right after by "udevadm trigger" may then get lost, so that no module is loaded at boot.

Starting network: Waiting for interface eth0 to appear............... timeout!

Wait until udevd answers on its control socket before triggering the events. The udevadm control command of eudev has no --ping option, so use --start-exec-queue, which has no effect on a daemon whose queue is already running.

While at it, return right away when udevd fails to start, as there is no point in triggering events then.

Quoted 6 lines
Quoted 1 line
Fixes 41258a81948fddfa7fc8ac06b69d77fa051b744d ("package/eudev: refactor init script and rename it to S10udevd")

Sorry, I know this is already committed - But if the bug was introduced by the move to backgrounding with start-stop-daemon, wouldn't it be simpler to just drop the --background argument to start-stop-daemon and instead ask udevd to background itself with -d like we did before?

The problem is that eudev doesn't write a PID file, and if we don't let start-stop-daemon handle backgrounding the one it writes will be wrong (before commit 41258a81948fddfa7fc8ac06b69d77fa051b744d, the init script didn't create one at all). :-(

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

#4 lore raw
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Fiona" == Fiona Klute <[email protected]> writes:

Hi,

Quoted 8 lines
Quoted 3 lines

by the move to backgrounding with start-stop-daemon, wouldn't it be simpler to just drop the --background argument to start-stop-daemon and instead ask udevd to background itself with -d like we did before?

The problem is that eudev doesn't write a PID file, and if we don't let start-stop-daemon handle backgrounding the one it writes will be wrong (before commit 41258a81948fddfa7fc8ac06b69d77fa051b744d, the init script didn't create one at all). :-(

True. Is there any uses for having more than 1 udevd on a system?

Signature · 5 lines
Bye, Peter Korsgaard
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#5 lore raw

Am 27.11.26 um 14:02 schrieb Peter Korsgaard:

Quoted 8 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Fiona" == Fiona Klute <[email protected]> writes:

Hi,

Quoted 3 lines
Quoted 3 lines

by the move to backgrounding with start-stop-daemon, wouldn't it be simpler to just drop the --background argument to start-stop-daemon and instead ask udevd to background itself with -d like we did before?

Quoted 6 lines
Quoted 4 lines

The problem is that eudev doesn't write a PID file, and if we don't let start-stop-daemon handle backgrounding the one it writes will be wrong (before commit 41258a81948fddfa7fc8ac06b69d77fa051b744d, the init script didn't create one at all). :-(

True. Is there any uses for having more than 1 udevd on a system?

I can't think of one, maybe if someone is doing something really weird with containers.

Are you suggesting in that case we should run udevd without a PID file? I wouldn't like losing that tracking, but also I don't know if it'd solve the problem (that is, whether the starting process only exits once the forked one is ready).

Best regards,
Fiona

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

#6 lore raw
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Fiona" == Fiona Klute <[email protected]> writes:

Hi,

Quoted 9 lines
Quoted 1 line

True. Is there any uses for having more than 1 udevd on a system?

I can't think of one, maybe if someone is doing something really weird with containers.

Are you suggesting in that case we should run udevd without a PID file? I wouldn't like losing that tracking, but also I don't know if it'd solve the problem (that is, whether the starting process only exits once the forked one is ready).

Well, that is what we had before you reworked the script in commit 41258a8194, no?

So maybe the rework to use start-stop-daemon wasn't worth the extra complexity after all?

Signature · 5 lines
Bye, Peter Korsgaard
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#7 lore raw

Am 29.11.26 um 22:42 schrieb Peter Korsgaard:

Quoted 14 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Fiona" == Fiona Klute <[email protected]> writes:

Hi,

Quoted 9 lines
Quoted 1 line

True. Is there any uses for having more than 1 udevd on a system?

I can't think of one, maybe if someone is doing something really weird with containers.

Are you suggesting in that case we should run udevd without a PID file? I wouldn't like losing that tracking, but also I don't know if it'd solve the problem (that is, whether the starting process only exits once the forked one is ready).

Quoted 5 lines

Well, that is what we had before you reworked the script in commit 41258a8194, no?

So maybe the rework to use start-stop-daemon wasn't worth the extra complexity after all?

I disagree, being able to reliably track if the service is running and with which PID is important, see the many scripts with restart issues. There may be other ways to do that (say, cgroups), but I doubt they'd add less complexity to the init script. For Busybox init the probe is a reasonable solution. Of course, eudev writing its own PID file would be better.

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

#8 lore raw
In reply to Dario Binacchi

In reply of:

Quoted 12 lines

start-stop-daemon starts udevd in the background and returns before udevd listens to kernel events. The coldplug events generated right after by "udevadm trigger" may then get lost, so that no module is loaded at boot.

Starting network: Waiting for interface eth0 to appear............... timeout!

Wait until udevd answers on its control socket before triggering the events. The udevadm control command of eudev has no --ping option, so use --start-exec-queue, which has no effect on a daemon whose queue is already running.

Quoted 5 lines

While at it, return right away when udevd fails to start, as there is no point in triggering events then.

Fixes 41258a81948fddfa7fc8ac06b69d77fa051b744d ("package/eudev: refactor init script and rename it to S10udevd")

Applied to 2026.08.x. Thanks

Quoted 23 lines

---
Changes in v2:
- Return right away when udevd fails to start and move the wait loop out of the if statement.
- Use '[ "$i" -lt 50 ] || break' to leave the loop.
- Explain in the commit message why --start-exec-queue is used.

v1: https://lore.kernel.org/buildroot/[email protected]

 package/eudev/S10udevd | 9 +++++++++
 1 file changed, 9 insertions(+)
package/eudev/S10udevd +2 -0
index 8bb8f6eb3a01..8eb764f65215 100644
@@ -37,7 +37,16 @@ start() {
 		echo "OK"
 	else
 		echo "FAIL"
+		return "$status"
 	fi
+	# start-stop-daemon returns before udevd listens to kernel events.

package/eudev/S10udevd start() { · line 52

Quoted 10 lines
package/eudev/S10udevd +7 -0
+	# Wait for it, or the events triggered below may get lost.
+	i=0
+	while ! udevadm control --start-exec-queue 2>/dev/null; do
+		i=$((i + 1))
+		[ "$i" -lt 50 ] || break
+		sleep 0.1
+	done
 	udevadm trigger --type=subsystems --action=add
 	udevadm trigger --type=devices --action=add
 	udevadm settle --timeout=$SETTLE_TIMEOUT || echo "udevadm settle failed"

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot