mirror of
https://github.com/vale981/bspwm
synced 2025-03-05 18:01:37 -05:00
parent
c744b74bc9
commit
98fe29a638
1 changed files with 23 additions and 8 deletions
31
src/bspc.c
31
src/bspc.c
|
@ -27,6 +27,7 @@
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
|
#include <poll.h>
|
||||||
#include <sys/un.h>
|
#include <sys/un.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include "helpers.h"
|
#include "helpers.h"
|
||||||
|
@ -78,15 +79,29 @@ int main(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
|
|
||||||
int ret = EXIT_SUCCESS, nb;
|
int ret = EXIT_SUCCESS, nb;
|
||||||
while ((nb = recv(fd, rsp, sizeof(rsp)-1, 0)) > 0) {
|
|
||||||
rsp[nb] = '\0';
|
struct pollfd fds[] = {
|
||||||
if (rsp[0] == FAILURE_MESSAGE[0]) {
|
{fd, POLLIN, 0},
|
||||||
ret = EXIT_FAILURE;
|
{STDOUT_FILENO, POLLHUP, 0},
|
||||||
printf("%s", rsp + 1);
|
};
|
||||||
} else {
|
|
||||||
printf("%s", rsp);
|
while (poll(fds, 2, -1) > 0) {
|
||||||
|
if (fds[0].revents & POLLIN) {
|
||||||
|
if ((nb = recv(fd, rsp, sizeof(rsp)-1, 0)) > 0) {
|
||||||
|
rsp[nb] = '\0';
|
||||||
|
if (rsp[0] == FAILURE_MESSAGE[0]) {
|
||||||
|
ret = EXIT_FAILURE;
|
||||||
|
printf("%s", rsp + 1);
|
||||||
|
} else {
|
||||||
|
printf("%s", rsp);
|
||||||
|
}
|
||||||
|
fflush(stdout);
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else if (fds[1].revents & POLLHUP) {
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
fflush(stdout);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
close(fd);
|
close(fd);
|
||||||
|
|
Loading…
Add table
Reference in a new issue