Commit d88f8ed4 authored by Michal Berger's avatar Michal Berger Committed by Tomasz Zawadzki
Browse files

scripts/sync_dev_uevents: Adjust termination of the udevadm



This is needed for newer Bash where $! becomes the PID of the
udevadm instead of being its child. Not killing udevadm properly
in this case may be problematic in case the script was run from
the ssh session - depending on the setup, if not all children
of said session are dead, ssh may block forever waiting for them
to terminate (which won't happen as udevadm gets attached to 1
process instead of being reaped).

Signed-off-by: default avatarMichal Berger <michal.berger@intel.com>
Change-Id: I3248d0937e9dd919c054a97473f9bb998aa8ca63
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/15147


Reviewed-by: default avatarPawel Piatek <pawelx.piatek@intel.com>
Reviewed-by: default avatarKamil Godzwon <kamilx.godzwon@intel.com>
Reviewed-by: default avatarKarol Latecki <karol.latecki@intel.com>
Reviewed-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
parent 008139c8
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -113,8 +113,12 @@ if [[ -S /run/udev/control ]]; then
	# This trap targets a subshell which forks udevadm monitor. Since
	# process substitution works in an async fashion, $$ won't wait
	# for it, leaving it's child unattended after the main loop breaks
	# (udevadm won't exit on its own either).
	trap '[[ -e /proc/$!/status ]] && pkill -P $!' EXIT
	# (udevadm won't exit on its own either). UPDATE: This is not true
	# anymore for Bash >= 5.2 where executing process replaces the
	# actual subshell so $! becomes the PID of the udevadm instance.
	# To accommodate that, attempt to signal $! directly in case pkill
	# fails.
	trap '[[ ! -e /proc/$!/status ]] || pkill -P $! || kill $!' EXIT
	# Also, this will block while reading through a pipe with a timeout
	# after not receiving any input. stdbuf is used since udevadm always
	# line buffers the monitor output.