Linux non-blocking mounts

I use the Linux function mount(2)in a single-threaded process. But installing devices, such as a CD-ROM, may take some time (the worst I've seen is 40 seconds!), Since it takes a moment to think about it, part the disk, and only then mount the file system. This can block the process from processing other events for a considerable time.

I cannot find a way to mount the file system in a non-blocking way. Is there a way to mount a file system asynchronously without multithreading or forking?

Knowing whether the action is actually complete is not a problem for me, since I already read the uevents core in the same thread.

+3
source share
3 answers

No. Without starting another thread or fork()ing, you need to wait for a return mount().

+12
source

You can let the installation process run in the background. Installed as somthing like:

system("mount -a ");

Do

system("mount -a &");

This will fill the background in the background for you.

But, looking a little closer, this solution does not use the C interface, but the system interface

+2
source

, mount, , select() - . , forking mount() .

, mount(), ( ), - , , .

+1
source

Source: https://habr.com/ru/post/1702343/


All Articles