1
1
#include "fastfetch.h"
2
2
#include "common/processing.h"
3
3
#include "common/io/io.h"
4
- #include "common/time.h"
5
4
#include "util/stringUtils.h"
6
5
#include "util/mallocHelper.h"
7
6
@@ -90,6 +89,16 @@ const char* ffProcessAppendOutput(FFstrbuf* buffer, char* const argv[], bool use
90
89
waitpid (childPid , NULL , 0 );
91
90
return "poll(&pollfd, 1, timeout) timeout (try increasing --processing-timeout)" ;
92
91
}
92
+ else if (errno == EINTR )
93
+ {
94
+ // The child process has been terminated. See `chldSignalHandler` in `common/init.c`
95
+ if (waitpid (childPid , NULL , WNOHANG ) == childPid )
96
+ {
97
+ // Read remaining data from the pipe
98
+ fcntl (childPipeFd , F_SETFL , O_CLOEXEC | O_NONBLOCK );
99
+ childPid = -1 ;
100
+ }
101
+ }
93
102
else if (pollfd .revents & POLLERR )
94
103
{
95
104
kill (childPid , SIGTERM );
@@ -104,7 +113,7 @@ const char* ffProcessAppendOutput(FFstrbuf* buffer, char* const argv[], bool use
104
113
else if (nRead == 0 )
105
114
{
106
115
int stat_loc = 0 ;
107
- if (waitpid (childPid , & stat_loc , 0 ) == childPid )
116
+ if (childPid > 0 && waitpid (childPid , & stat_loc , 0 ) == childPid )
108
117
{
109
118
if (!WIFEXITED (stat_loc ))
110
119
return "child process exited abnormally" ;
@@ -113,10 +122,15 @@ const char* ffProcessAppendOutput(FFstrbuf* buffer, char* const argv[], bool use
113
122
// We only handle 127 as an error. See `getTerminalVersionUrxvt` in `terminalshell.c`
114
123
return NULL ;
115
124
}
116
- return "waitpid() failed" ;
125
+ return NULL ;
117
126
}
118
127
else if (nRead < 0 )
119
- break ;
128
+ {
129
+ if (errno == EAGAIN )
130
+ return NULL ;
131
+ else
132
+ break ;
133
+ }
120
134
};
121
135
122
136
return "read(childPipeFd, str, FF_PIPE_BUFSIZ) failed" ;
0 commit comments