Major bugfix related to pidfile
This commit is contained in:
parent
ef4238d88e
commit
d021510bad
|
@ -326,14 +326,14 @@ writepid()
|
||||||
int fd;
|
int fd;
|
||||||
struct flock fl;
|
struct flock fl;
|
||||||
|
|
||||||
fd = open(LOCKFILE, O_RDWR|O_CREAT, 0644);
|
fd = open(LOCKFILE, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
|
||||||
if (fd == -1) {
|
if (fd == -1) {
|
||||||
perror("writepid - open");
|
perror("writepid - open");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
fl.l_type = F_WRLCK;
|
fl.l_type = F_WRLCK;
|
||||||
fl.l_start = 0;
|
|
||||||
fl.l_whence = SEEK_SET;
|
fl.l_whence = SEEK_SET;
|
||||||
|
fl.l_start = 0;
|
||||||
fl.l_len = 0;
|
fl.l_len = 0;
|
||||||
if (fcntl(fd, F_SETLK, &fl) == -1) {
|
if (fcntl(fd, F_SETLK, &fl) == -1) {
|
||||||
if (errno == EACCES || errno == EAGAIN) {
|
if (errno == EACCES || errno == EAGAIN) {
|
||||||
|
|
|
@ -43,7 +43,7 @@ diff -ruN dwm-6.2-ori/config.def.h dwm-6.2/config.def.h
|
||||||
{ ClkClientWin, MODKEY, Button3, resizemouse, {0} },
|
{ ClkClientWin, MODKEY, Button3, resizemouse, {0} },
|
||||||
diff -ruN dwm-6.2-ori/dwm.c dwm-6.2/dwm.c
|
diff -ruN dwm-6.2-ori/dwm.c dwm-6.2/dwm.c
|
||||||
--- dwm-6.2-ori/dwm.c 2019-02-02 18:25:28.000000000 +0530
|
--- dwm-6.2-ori/dwm.c 2019-02-02 18:25:28.000000000 +0530
|
||||||
+++ dwm-6.2/dwm.c 2020-12-30 16:24:10.847012386 +0530
|
+++ dwm-6.2/dwm.c 2021-01-10 05:23:06.472038418 +0530
|
||||||
@@ -40,6 +40,7 @@
|
@@ -40,6 +40,7 @@
|
||||||
#include <X11/extensions/Xinerama.h>
|
#include <X11/extensions/Xinerama.h>
|
||||||
#endif /* XINERAMA */
|
#endif /* XINERAMA */
|
||||||
|
@ -277,28 +277,40 @@ diff -ruN dwm-6.2-ori/dwm.c dwm-6.2/dwm.c
|
||||||
cursor[CurResize] = drw_cur_create(drw, XC_sizing);
|
cursor[CurResize] = drw_cur_create(drw, XC_sizing);
|
||||||
cursor[CurMove] = drw_cur_create(drw, XC_fleur);
|
cursor[CurMove] = drw_cur_create(drw, XC_fleur);
|
||||||
/* init appearance */
|
/* init appearance */
|
||||||
@@ -1637,6 +1689,28 @@
|
@@ -1637,6 +1689,40 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
+sigdwmblocks(const Arg *arg)
|
+sigdwmblocks(const Arg *arg)
|
||||||
+{
|
+{
|
||||||
+ int fd;
|
+ static int fd = -1;
|
||||||
+ struct flock fl;
|
+ struct flock fl;
|
||||||
+ union sigval sv;
|
+ union sigval sv;
|
||||||
+
|
+
|
||||||
+ if (!dwmblockssig)
|
+ if (!dwmblockssig)
|
||||||
+ return;
|
+ return;
|
||||||
+ sv.sival_int = (dwmblockssig << 8) | arg->i;
|
|
||||||
+ fd = open(DWMBLOCKSLOCKFILE, O_RDONLY);
|
|
||||||
+ if (fd == -1)
|
|
||||||
+ return;
|
|
||||||
+ fl.l_type = F_WRLCK;
|
+ fl.l_type = F_WRLCK;
|
||||||
+ fl.l_start = 0;
|
|
||||||
+ fl.l_whence = SEEK_SET;
|
+ fl.l_whence = SEEK_SET;
|
||||||
|
+ fl.l_start = 0;
|
||||||
+ fl.l_len = 0;
|
+ fl.l_len = 0;
|
||||||
|
+ if (fd == -1) {
|
||||||
|
+ if ((fd = open(DWMBLOCKSLOCKFILE, O_RDONLY)) == -1)
|
||||||
|
+ return;
|
||||||
+ if (fcntl(fd, F_GETLK, &fl) == -1 || fl.l_type == F_UNLCK)
|
+ if (fcntl(fd, F_GETLK, &fl) == -1 || fl.l_type == F_UNLCK)
|
||||||
+ return;
|
+ return;
|
||||||
|
+ } else {
|
||||||
|
+ if (fcntl(fd, F_GETLK, &fl) == -1)
|
||||||
|
+ return;
|
||||||
|
+ if (fl.l_type == F_UNLCK) {
|
||||||
|
+ close(fd);
|
||||||
|
+ if ((fd = open(DWMBLOCKSLOCKFILE, O_RDONLY)) == -1)
|
||||||
|
+ return;
|
||||||
|
+ fl.l_type = F_WRLCK;
|
||||||
|
+ if (fcntl(fd, F_GETLK, &fl) == -1 || fl.l_type == F_UNLCK)
|
||||||
|
+ return;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ sv.sival_int = (dwmblockssig << 8) | arg->i;
|
||||||
+ sigqueue(fl.l_pid, SIGRTMIN, sv);
|
+ sigqueue(fl.l_pid, SIGRTMIN, sv);
|
||||||
+}
|
+}
|
||||||
+
|
+
|
||||||
|
@ -306,7 +318,7 @@ diff -ruN dwm-6.2-ori/dwm.c dwm-6.2/dwm.c
|
||||||
spawn(const Arg *arg)
|
spawn(const Arg *arg)
|
||||||
{
|
{
|
||||||
if (arg->v == dmenucmd)
|
if (arg->v == dmenucmd)
|
||||||
@@ -1805,7 +1879,7 @@
|
@@ -1805,7 +1891,7 @@
|
||||||
XSetWindowAttributes wa = {
|
XSetWindowAttributes wa = {
|
||||||
.override_redirect = True,
|
.override_redirect = True,
|
||||||
.background_pixmap = ParentRelative,
|
.background_pixmap = ParentRelative,
|
||||||
|
@ -315,7 +327,7 @@ diff -ruN dwm-6.2-ori/dwm.c dwm-6.2/dwm.c
|
||||||
};
|
};
|
||||||
XClassHint ch = {"dwm", "dwm"};
|
XClassHint ch = {"dwm", "dwm"};
|
||||||
for (m = mons; m; m = m->next) {
|
for (m = mons; m; m = m->next) {
|
||||||
@@ -1847,6 +1921,41 @@
|
@@ -1847,6 +1933,41 @@
|
||||||
(unsigned char *) &(c->win), 1);
|
(unsigned char *) &(c->win), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -357,7 +369,7 @@ diff -ruN dwm-6.2-ori/dwm.c dwm-6.2/dwm.c
|
||||||
int
|
int
|
||||||
updategeom(void)
|
updategeom(void)
|
||||||
{
|
{
|
||||||
@@ -1987,9 +2096,27 @@
|
@@ -1987,9 +2108,27 @@
|
||||||
void
|
void
|
||||||
updatestatus(void)
|
updatestatus(void)
|
||||||
{
|
{
|
||||||
|
|
|
@ -43,7 +43,7 @@ diff -ruN dwm-6.2-ori/config.def.h dwm-6.2/config.def.h
|
||||||
{ ClkClientWin, MODKEY, Button3, resizemouse, {0} },
|
{ ClkClientWin, MODKEY, Button3, resizemouse, {0} },
|
||||||
diff -ruN dwm-6.2-ori/dwm.c dwm-6.2/dwm.c
|
diff -ruN dwm-6.2-ori/dwm.c dwm-6.2/dwm.c
|
||||||
--- dwm-6.2-ori/dwm.c 2020-08-17 23:51:19.057243495 +0530
|
--- dwm-6.2-ori/dwm.c 2020-08-17 23:51:19.057243495 +0530
|
||||||
+++ dwm-6.2/dwm.c 2020-12-30 16:26:04.168439847 +0530
|
+++ dwm-6.2/dwm.c 2021-01-10 05:24:06.575894250 +0530
|
||||||
@@ -40,6 +40,7 @@
|
@@ -40,6 +40,7 @@
|
||||||
#include <X11/extensions/Xinerama.h>
|
#include <X11/extensions/Xinerama.h>
|
||||||
#endif /* XINERAMA */
|
#endif /* XINERAMA */
|
||||||
|
@ -314,28 +314,40 @@ diff -ruN dwm-6.2-ori/dwm.c dwm-6.2/dwm.c
|
||||||
cursor[CurResize] = drw_cur_create(drw, XC_sizing);
|
cursor[CurResize] = drw_cur_create(drw, XC_sizing);
|
||||||
cursor[CurMove] = drw_cur_create(drw, XC_fleur);
|
cursor[CurMove] = drw_cur_create(drw, XC_fleur);
|
||||||
/* init appearance */
|
/* init appearance */
|
||||||
@@ -1825,6 +1881,28 @@
|
@@ -1825,6 +1881,40 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
+sigdwmblocks(const Arg *arg)
|
+sigdwmblocks(const Arg *arg)
|
||||||
+{
|
+{
|
||||||
+ int fd;
|
+ static int fd = -1;
|
||||||
+ struct flock fl;
|
+ struct flock fl;
|
||||||
+ union sigval sv;
|
+ union sigval sv;
|
||||||
+
|
+
|
||||||
+ if (!dwmblockssig)
|
+ if (!dwmblockssig)
|
||||||
+ return;
|
+ return;
|
||||||
+ sv.sival_int = (dwmblockssig << 8) | arg->i;
|
|
||||||
+ fd = open(DWMBLOCKSLOCKFILE, O_RDONLY);
|
|
||||||
+ if (fd == -1)
|
|
||||||
+ return;
|
|
||||||
+ fl.l_type = F_WRLCK;
|
+ fl.l_type = F_WRLCK;
|
||||||
+ fl.l_start = 0;
|
|
||||||
+ fl.l_whence = SEEK_SET;
|
+ fl.l_whence = SEEK_SET;
|
||||||
|
+ fl.l_start = 0;
|
||||||
+ fl.l_len = 0;
|
+ fl.l_len = 0;
|
||||||
|
+ if (fd == -1) {
|
||||||
|
+ if ((fd = open(DWMBLOCKSLOCKFILE, O_RDONLY)) == -1)
|
||||||
|
+ return;
|
||||||
+ if (fcntl(fd, F_GETLK, &fl) == -1 || fl.l_type == F_UNLCK)
|
+ if (fcntl(fd, F_GETLK, &fl) == -1 || fl.l_type == F_UNLCK)
|
||||||
+ return;
|
+ return;
|
||||||
|
+ } else {
|
||||||
|
+ if (fcntl(fd, F_GETLK, &fl) == -1)
|
||||||
|
+ return;
|
||||||
|
+ if (fl.l_type == F_UNLCK) {
|
||||||
|
+ close(fd);
|
||||||
|
+ if ((fd = open(DWMBLOCKSLOCKFILE, O_RDONLY)) == -1)
|
||||||
|
+ return;
|
||||||
|
+ fl.l_type = F_WRLCK;
|
||||||
|
+ if (fcntl(fd, F_GETLK, &fl) == -1 || fl.l_type == F_UNLCK)
|
||||||
|
+ return;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ sv.sival_int = (dwmblockssig << 8) | arg->i;
|
||||||
+ sigqueue(fl.l_pid, SIGRTMIN, sv);
|
+ sigqueue(fl.l_pid, SIGRTMIN, sv);
|
||||||
+}
|
+}
|
||||||
+
|
+
|
||||||
|
@ -343,7 +355,7 @@ diff -ruN dwm-6.2-ori/dwm.c dwm-6.2/dwm.c
|
||||||
spawn(const Arg *arg)
|
spawn(const Arg *arg)
|
||||||
{
|
{
|
||||||
if (arg->v == dmenucmd)
|
if (arg->v == dmenucmd)
|
||||||
@@ -2011,7 +2089,7 @@
|
@@ -2011,7 +2101,7 @@
|
||||||
XSetWindowAttributes wa = {
|
XSetWindowAttributes wa = {
|
||||||
.override_redirect = True,
|
.override_redirect = True,
|
||||||
.background_pixmap = ParentRelative,
|
.background_pixmap = ParentRelative,
|
||||||
|
@ -352,7 +364,7 @@ diff -ruN dwm-6.2-ori/dwm.c dwm-6.2/dwm.c
|
||||||
};
|
};
|
||||||
XClassHint ch = {"dwm", "dwm"};
|
XClassHint ch = {"dwm", "dwm"};
|
||||||
for (m = mons; m; m = m->next) {
|
for (m = mons; m; m = m->next) {
|
||||||
@@ -2058,6 +2136,41 @@
|
@@ -2058,6 +2148,41 @@
|
||||||
(unsigned char *) &(c->win), 1);
|
(unsigned char *) &(c->win), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -394,7 +406,7 @@ diff -ruN dwm-6.2-ori/dwm.c dwm-6.2/dwm.c
|
||||||
int
|
int
|
||||||
updategeom(void)
|
updategeom(void)
|
||||||
{
|
{
|
||||||
@@ -2198,10 +2311,27 @@
|
@@ -2198,10 +2323,27 @@
|
||||||
void
|
void
|
||||||
updatestatus(void)
|
updatestatus(void)
|
||||||
{
|
{
|
||||||
|
|
|
@ -60,13 +60,15 @@ sendsignal(int sig, union sigval sv)
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
fl.l_type = F_WRLCK;
|
fl.l_type = F_WRLCK;
|
||||||
fl.l_start = 0;
|
|
||||||
fl.l_whence = SEEK_SET;
|
fl.l_whence = SEEK_SET;
|
||||||
|
fl.l_start = 0;
|
||||||
fl.l_len = 0;
|
fl.l_len = 0;
|
||||||
if (fcntl(fd, F_GETLK, &fl) == -1) {
|
if (fcntl(fd, F_GETLK, &fl) == -1) {
|
||||||
perror("sendsignal - fcntl");
|
perror("sendsignal - fcntl");
|
||||||
|
close(fd);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
close(fd);
|
||||||
if (fl.l_type == F_UNLCK) {
|
if (fl.l_type == F_UNLCK) {
|
||||||
fputs("Error: no running instance of dwmblocks.\n", stderr);
|
fputs("Error: no running instance of dwmblocks.\n", stderr);
|
||||||
exit(3);
|
exit(3);
|
||||||
|
|
Loading…
Reference in a new issue