Re: block till hotplug is done?

From: Valdis . Kletnieks
Date: Tue Oct 05 2004 - 15:44:58 EST


On Tue, 05 Oct 2004 22:13:15 +0200, Harald Dunkel said:
> Andreas Jellinghaus wrote:
> > Hi,
> >
> > is there any way to block till all hotplug events are handled/
> > the hotplug processes terminated?
> >
>
> while [ "`ps | grep /sbin/hotplug | grep -v grep`" ]; do sleep 1; done

Save a process:

while [ "`ps | grep '/sbin/[h]otplug'`" ]; do sleep 1; done

Depending on what exactly you're waiting on, you might also try:

while [ ! -b /dev/hdc1 ]; do sleep 1; done

(Assuming you know what device name you're expecting - this may depend on
the exact list of things that you want to do - there *might* be a race
condition where fdisk has created hd?1 but it's not the *right* one because
the media was previously partitioned and fdisk hasn't told the kernel to
read the new one yet. YMMV and all that...)

Attachment: pgp00000.pgp
Description: PGP signature