Skip to content

Commit 7abdfe4

Browse files
committed
Revert "Replace sigmask/pselect with self-pipe trick"
Reverting in favor of martanne#69. This reverts commit 52e85ef.
1 parent 5e8d655 commit 7abdfe4

File tree

1 file changed

+9
-17
lines changed

1 file changed

+9
-17
lines changed

dvtm.c

+9-17
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,6 @@ int ESCDELAY;
4646
# define set_escdelay(d) (ESCDELAY = (d))
4747
#endif
4848

49-
int selfpipe[2];
50-
#define SELFPIPE_READ 0
51-
#define SELFPIPE_WRITE 1
52-
5349
typedef struct {
5450
float mfact;
5551
unsigned int nmaster;
@@ -762,7 +758,6 @@ get_tag_by_coord(unsigned int x, unsigned int y) {
762758
static void
763759
sigchld_handler(int sig) {
764760
screen.need_check_deaths = true;
765-
write(selfpipe[SELFPIPE_WRITE], "", 1);
766761
}
767762

768763
static void
@@ -801,13 +796,11 @@ check_deaths() {
801796
static void
802797
sigwinch_handler(int sig) {
803798
screen.need_resize = true;
804-
write(selfpipe[SELFPIPE_WRITE], "", 1);
805799
}
806800

807801
static void
808802
sigterm_handler(int sig) {
809803
running = false;
810-
write(selfpipe[SELFPIPE_WRITE], "", 1);
811804
}
812805

813806
static void
@@ -1089,7 +1082,6 @@ setup(void) {
10891082
}
10901083
initpertag();
10911084
resize_screen();
1092-
pipe(selfpipe);
10931085
struct sigaction sa;
10941086
memset(&sa, 0, sizeof sa);
10951087
sa.sa_flags = 0;
@@ -1974,13 +1966,20 @@ int
19741966
main(int argc, char *argv[]) {
19751967
unsigned int key_index = 0;
19761968
memset(keys, 0, sizeof(keys));
1969+
sigset_t emptyset, blockset;
19771970

19781971
setenv("DVTM", VERSION, 1);
19791972
if (!parse_args(argc, argv)) {
19801973
setup();
19811974
startup(NULL);
19821975
}
19831976

1977+
sigemptyset(&emptyset);
1978+
sigemptyset(&blockset);
1979+
sigaddset(&blockset, SIGWINCH);
1980+
sigaddset(&blockset, SIGCHLD);
1981+
sigprocmask(SIG_BLOCK, &blockset, NULL);
1982+
19841983
while (running) {
19851984
int r, nfds = 0;
19861985
fd_set rd;
@@ -1997,12 +1996,10 @@ main(int argc, char *argv[]) {
19971996

19981997
FD_ZERO(&rd);
19991998
FD_SET(STDIN_FILENO, &rd);
2000-
FD_SET(selfpipe[SELFPIPE_READ], &rd);
2001-
nfds = MAX(nfds, selfpipe[SELFPIPE_READ]);
20021999

20032000
if (cmdfifo.fd != -1) {
20042001
FD_SET(cmdfifo.fd, &rd);
2005-
nfds = MAX(nfds, cmdfifo.fd);
2002+
nfds = cmdfifo.fd;
20062003
}
20072004

20082005
if (bar.fd != -1) {
@@ -2026,7 +2023,7 @@ main(int argc, char *argv[]) {
20262023
}
20272024

20282025
doupdate();
2029-
r = select(nfds + 1, &rd, NULL, NULL, NULL);
2026+
r = pselect(nfds + 1, &rd, NULL, NULL, NULL, &emptyset);
20302027

20312028
if (r < 0) {
20322029
if (errno == EINTR)
@@ -2065,11 +2062,6 @@ main(int argc, char *argv[]) {
20652062
continue;
20662063
}
20672064

2068-
if (FD_ISSET(selfpipe[SELFPIPE_READ], &rd)) {
2069-
char buf[8];
2070-
read(selfpipe[SELFPIPE_READ], &buf, sizeof(buf));
2071-
}
2072-
20732065
if (cmdfifo.fd != -1 && FD_ISSET(cmdfifo.fd, &rd))
20742066
handle_cmdfifo();
20752067

0 commit comments

Comments
 (0)