@@ -46,10 +46,6 @@ int ESCDELAY;
46
46
# define set_escdelay (d ) (ESCDELAY = (d))
47
47
#endif
48
48
49
- int selfpipe [2 ];
50
- #define SELFPIPE_READ 0
51
- #define SELFPIPE_WRITE 1
52
-
53
49
typedef struct {
54
50
float mfact ;
55
51
unsigned int nmaster ;
@@ -762,7 +758,6 @@ get_tag_by_coord(unsigned int x, unsigned int y) {
762
758
static void
763
759
sigchld_handler (int sig ) {
764
760
screen .need_check_deaths = true;
765
- write (selfpipe [SELFPIPE_WRITE ], "" , 1 );
766
761
}
767
762
768
763
static void
@@ -801,13 +796,11 @@ check_deaths() {
801
796
static void
802
797
sigwinch_handler (int sig ) {
803
798
screen .need_resize = true;
804
- write (selfpipe [SELFPIPE_WRITE ], "" , 1 );
805
799
}
806
800
807
801
static void
808
802
sigterm_handler (int sig ) {
809
803
running = false;
810
- write (selfpipe [SELFPIPE_WRITE ], "" , 1 );
811
804
}
812
805
813
806
static void
@@ -1089,7 +1082,6 @@ setup(void) {
1089
1082
}
1090
1083
initpertag ();
1091
1084
resize_screen ();
1092
- pipe (selfpipe );
1093
1085
struct sigaction sa ;
1094
1086
memset (& sa , 0 , sizeof sa );
1095
1087
sa .sa_flags = 0 ;
@@ -1974,13 +1966,20 @@ int
1974
1966
main (int argc , char * argv []) {
1975
1967
unsigned int key_index = 0 ;
1976
1968
memset (keys , 0 , sizeof (keys ));
1969
+ sigset_t emptyset , blockset ;
1977
1970
1978
1971
setenv ("DVTM" , VERSION , 1 );
1979
1972
if (!parse_args (argc , argv )) {
1980
1973
setup ();
1981
1974
startup (NULL );
1982
1975
}
1983
1976
1977
+ sigemptyset (& emptyset );
1978
+ sigemptyset (& blockset );
1979
+ sigaddset (& blockset , SIGWINCH );
1980
+ sigaddset (& blockset , SIGCHLD );
1981
+ sigprocmask (SIG_BLOCK , & blockset , NULL );
1982
+
1984
1983
while (running ) {
1985
1984
int r , nfds = 0 ;
1986
1985
fd_set rd ;
@@ -1997,12 +1996,10 @@ main(int argc, char *argv[]) {
1997
1996
1998
1997
FD_ZERO (& rd );
1999
1998
FD_SET (STDIN_FILENO , & rd );
2000
- FD_SET (selfpipe [SELFPIPE_READ ], & rd );
2001
- nfds = MAX (nfds , selfpipe [SELFPIPE_READ ]);
2002
1999
2003
2000
if (cmdfifo .fd != -1 ) {
2004
2001
FD_SET (cmdfifo .fd , & rd );
2005
- nfds = MAX ( nfds , cmdfifo .fd ) ;
2002
+ nfds = cmdfifo .fd ;
2006
2003
}
2007
2004
2008
2005
if (bar .fd != -1 ) {
@@ -2026,7 +2023,7 @@ main(int argc, char *argv[]) {
2026
2023
}
2027
2024
2028
2025
doupdate ();
2029
- r = select (nfds + 1 , & rd , NULL , NULL , NULL );
2026
+ r = pselect (nfds + 1 , & rd , NULL , NULL , NULL , & emptyset );
2030
2027
2031
2028
if (r < 0 ) {
2032
2029
if (errno == EINTR )
@@ -2065,11 +2062,6 @@ main(int argc, char *argv[]) {
2065
2062
continue ;
2066
2063
}
2067
2064
2068
- if (FD_ISSET (selfpipe [SELFPIPE_READ ], & rd )) {
2069
- char buf [8 ];
2070
- read (selfpipe [SELFPIPE_READ ], & buf , sizeof (buf ));
2071
- }
2072
-
2073
2065
if (cmdfifo .fd != -1 && FD_ISSET (cmdfifo .fd , & rd ))
2074
2066
handle_cmdfifo ();
2075
2067
0 commit comments