Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ugly loop may have serious impact on udev on Disco #36

Closed
BadWolf42 opened this issue Aug 26, 2018 · 2 comments
Closed

Ugly loop may have serious impact on udev on Disco #36

BadWolf42 opened this issue Aug 26, 2018 · 2 comments

Comments

@BadWolf42
Copy link

Hello,

I went through the Disco4G code and it's an impressive work!
I wondered why the program is kept running when I stumble on the "Uggly loop" :

ulogger -s -t uavpal_disco "... looping to keep script alive. ugly, yes!"
ulogger -s -t uavpal_disco "*** idle on LTE ***"
while true; do sleep 10; done

As explained here: http://reactivated.net/writing_udev_rules.html

This program can act on the device, however it must not run for any extended period of time, because udev is effectively paused while these programs are running. One workaround for this limitation is to make sure your program immediately detaches itself.

Two options :

  • If the program doesn't have to run continuously and is just here to check if it has been run, a lock file, containing the script PID while running and 0 upon successful execution, can be created to avoid a re-run.
  • If it is mandatory for the program to run continuously, the best way is to create a daemon and start it in the udev rule. The daemon init script will check if it's already running and the appropriate action to take.

What do you think ?
I have the knowledge to implement both scenario but prefer to ask for your lights and guidance first ;)

Regards,
Bad

@uavpal
Copy link
Collaborator

uavpal commented Aug 28, 2018

Thanks BadWolf, the loop can and will be removed in the next release. It is apparently not necessary anymore as all processes initiated by uavpal_disco.sh (scripts and daemons) are detached/non-blocking.
SoftIce

@uavpal
Copy link
Collaborator

uavpal commented Aug 28, 2018

2910e6b

@uavpal uavpal closed this as completed Aug 28, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant