UtkarshVerma / dwmblocks-async

An efficient, lean, and asynchronous status feed generator for dwm.
GNU General Public License v2.0
232 stars 87 forks source link

Suggestion: alarm #18

Closed explosion-mental closed 2 years ago

explosion-mental commented 2 years ago

Hello, what about using alarm to notify the parent?

UtkarshVerma commented 2 years ago

Using this would get rid of the child process, but timing the intervals accurately would be hard.

I'll have a look but AFAIK, using alarm() in the parent will lead to some inaccuracies. If it's within acceptable bounds, then implementing it would be worth it.

explosion-mental commented 2 years ago

yeah no need for the timer loop. I've implemented this in my dwm https://github.com/explosion-mental/Dwm/blob/d056028b8df0d7286df0cf29effa5c296bcbd0d9/dwm.c#L3461 with the same logic of dwmblocks-async

explosion-mental commented 2 years ago

I'll have a look but AFAIK, using alarm() in the parent will lead to some inaccuracies.

Like? I have an interval of 10 seconds. Havent tested with less time. The less you can go is with 1 second, but probably if you have a block update every second would mean to send a signal every seconds and im not sure if thats 'safe' at all.

UtkarshVerma commented 2 years ago

That's safe, because signals are queued. What's going to be difficult is only executing alarm() once per interval inside the while loop.

explosion-mental commented 2 years ago

calling alarm in the handler, func I showed u above, and before the loop should do the trick

explosion-mental commented 2 years ago

oh and off topic but, thought about using poll? only reason being portability I guess

UtkarshVerma commented 2 years ago

Thank you for the suggestion @explosion-mental . I have redone the timer logic using alarm() through 23e1d5732a8c9eb0d811a49cea151c066627edcb due to which the codebase is a bit simpler now. Moreover, there won't be any need to apply the pgrep modification to the dwm source now.

Regarding your suggestion about poll. I'd stick to epoll for now and wait until an issue pops up in the future, if at all.

I am closing this issue, please feel free to reopen it.

UtkarshVerma commented 12 months ago

@explosion-mental I did a rewrite for this project utilising POSIX-compliant features. Let me know if that does the job for you.