Use setitimer instead of alarm
This commit is contained in:
parent
abf71d99b9
commit
99e85cbfc2
29
src/wmfs.c
29
src/wmfs.c
@ -141,6 +141,26 @@ quit(void)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** launch status timer
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
status_timer(void)
|
||||||
|
{
|
||||||
|
struct itimerval timer = {
|
||||||
|
.it_interval = {
|
||||||
|
.tv_usec = 0,
|
||||||
|
.tv_sec = conf.status_timing,
|
||||||
|
},
|
||||||
|
.it_value = {
|
||||||
|
.tv_usec = 1,
|
||||||
|
.tv_sec = 0,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
signal(SIGALRM, &signal_handle);
|
||||||
|
setitimer(ITIMER_REAL, &timer, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
/** WMFS main loop.
|
/** WMFS main loop.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
@ -148,10 +168,6 @@ mainloop(void)
|
|||||||
{
|
{
|
||||||
XEvent ev;
|
XEvent ev;
|
||||||
|
|
||||||
/* launch status loop */
|
|
||||||
if (estatus)
|
|
||||||
signal_handle(SIGALRM);
|
|
||||||
|
|
||||||
while(!exiting && !XNextEvent(dpy, &ev))
|
while(!exiting && !XNextEvent(dpy, &ev))
|
||||||
getevent(ev);
|
getevent(ev);
|
||||||
|
|
||||||
@ -400,9 +416,6 @@ signal_handle(int sig)
|
|||||||
/* exec status script (only if still not running) */
|
/* exec status script (only if still not running) */
|
||||||
if (conf.status_pid == (pid_t)-1)
|
if (conf.status_pid == (pid_t)-1)
|
||||||
conf.status_pid = spawn(conf.status_path);
|
conf.status_pid = spawn(conf.status_path);
|
||||||
/* re-set timer */
|
|
||||||
if (conf.status_timing > 0)
|
|
||||||
alarm(conf.status_timing);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -513,6 +526,8 @@ main(int argc, char **argv)
|
|||||||
/* Let's Go ! */
|
/* Let's Go ! */
|
||||||
init();
|
init();
|
||||||
scan();
|
scan();
|
||||||
|
if (estatus)
|
||||||
|
status_timer();
|
||||||
mainloop();
|
mainloop();
|
||||||
quit();
|
quit();
|
||||||
|
|
||||||
|
|||||||
@ -52,6 +52,7 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
#include <sys/time.h>
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
#include <X11/Xatom.h>
|
#include <X11/Xatom.h>
|
||||||
#include <X11/cursorfont.h>
|
#include <X11/cursorfont.h>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user