fix?
This commit is contained in:
parent
d482e0647f
commit
49fb1af798
1 changed files with 6 additions and 4 deletions
|
@ -16,7 +16,7 @@ int main() {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
const char *send_fifo_path = "fifos/send_fifo";
|
const char *send_fifo_path = "fifos/send_fifo";
|
||||||
if (faccessat(AT_FDCWD,send_fifo_path, F_OK,AT_EACCESS) != -1) {
|
if (faccessat(AT_FDCWD, send_fifo_path, F_OK, AT_EACCESS) != -1) {
|
||||||
// FIFO exists, delete it
|
// FIFO exists, delete it
|
||||||
if (unlink(send_fifo_path) == -1) {
|
if (unlink(send_fifo_path) == -1) {
|
||||||
perror("unlink");
|
perror("unlink");
|
||||||
|
@ -32,7 +32,7 @@ int main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
int send_fifo_fd;
|
int send_fifo_fd;
|
||||||
send_fifo_fd = open(send_fifo_path, O_RDONLY);
|
send_fifo_fd = open(send_fifo_path, O_RDWR);
|
||||||
if (send_fifo_fd == -1) {
|
if (send_fifo_fd == -1) {
|
||||||
if (errno == ENOENT) {
|
if (errno == ENOENT) {
|
||||||
// FIFO does not exist
|
// FIFO does not exist
|
||||||
|
@ -47,7 +47,9 @@ int main() {
|
||||||
while (1) {
|
while (1) {
|
||||||
// Read message from the send_fifo
|
// Read message from the send_fifo
|
||||||
unsigned char buffer[MESSAGE_SIZE];
|
unsigned char buffer[MESSAGE_SIZE];
|
||||||
read(send_fifo_fd, buffer, MESSAGE_SIZE);
|
if (read(send_fifo_fd, buffer, MESSAGE_SIZE) == 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
// Deserialize the message
|
// Deserialize the message
|
||||||
message msg;
|
message msg;
|
||||||
deserialize_message(buffer, MESSAGE_SIZE, &msg);
|
deserialize_message(buffer, MESSAGE_SIZE, &msg);
|
||||||
|
@ -97,7 +99,7 @@ int main() {
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct passwd *pw = getpwuid(msg.header.receiver);
|
struct passwd *pw = getpwuid(msg.header.receiver);
|
||||||
if (pw == NULL) {
|
if (pw == NULL) {
|
||||||
fprintf(stderr, "User with uid %d not found\n", msg.header.receiver);
|
fprintf(stderr, "User with uid %d not found\n", msg.header.receiver);
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
|
|
Loading…
Reference in a new issue