LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   How to get event when device creation is completed by mknod on linux Ubuntu 8.04? (https://www.linuxquestions.org/questions/programming-9/how-to-get-event-when-device-creation-is-completed-by-mknod-on-linux-ubuntu-8-04-a-745225/)

ankur_hill 08-05-2009 03:58 AM

How to get event when device creation is completed by mknod on linux Ubuntu 8.04?
 
Hi,


I need to use a device (/dev/ttyS5) which is created by a process which is launched by my program.

However, after launching the process, it takes some time for /dev/ttyS5 device to come up.

hence i need to use sleep() for for 3~4 seconds after launching the process and hope that device becomes ready by that time.

is there any way to get some kind or signal or event by which i can know if device is ready? sleep() is really bad way to handle this situation.


regards,
Anks

PS: Child process that I am launching is not written by me. hence its not possible for me to modify its source code.

jf.argentino 08-05-2009 07:59 AM

Maybe a trick like:
Code:

while (open ("/dev/ttyS5", "r") < 0) {
  usleep (100000);
}


ankur_hill 08-06-2009 07:21 AM

Quote:

Originally Posted by jf.argentino (Post 3632200)
Maybe a trick like:
Code:

while (open ("/dev/ttyS5", "r") < 0) {
  usleep (100000);
}


Yes that is a nice trick! actually i was thinking if it would be possible to receive some event when device is ready. but i guess this is the only way.

thanks Argentino!

regards,
Ankur


All times are GMT -5. The time now is 02:49 AM.