Fixed that seed wouldn't close on exec
This commit is contained in:
parent
15384083a0
commit
bdfbf4bebe
3 changed files with 14 additions and 4 deletions
|
@ -57,7 +57,7 @@ init_socket(void)
|
|||
#define CMDIS(c) (strcmp(command, (c)) == 0)
|
||||
|
||||
void
|
||||
handle_ipc_event(char *msg)
|
||||
handle_ipc_event(FILE *client, char *msg)
|
||||
{
|
||||
char *command = strtok(msg, " ");
|
||||
|
||||
|
@ -67,6 +67,7 @@ handle_ipc_event(char *msg)
|
|||
exec_config();
|
||||
} else if (CMDIS("exec")) {
|
||||
char *command = strtok(NULL, "");
|
||||
fclose(client);
|
||||
execl("/bin/sh", "/bin/sh", "-c", command, NULL);
|
||||
g_is_about_to_quit = true;
|
||||
} else {
|
||||
|
|
|
@ -8,8 +8,10 @@
|
|||
#ifndef IPC_H
|
||||
#define IPC_H
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
void init_socket(void);
|
||||
void handle_ipc_event(char *msg);
|
||||
void handle_ipc_event(FILE *client, char *msg);
|
||||
|
||||
extern int g_sock_fd;
|
||||
|
||||
|
|
|
@ -117,8 +117,15 @@ main(int argc, char *argv[])
|
|||
if (!(client_fd < 0) && (msg_len = read(client_fd, msg, sizeof(msg) - 1)) > 0) {
|
||||
// client sent something
|
||||
msg[msg_len] = '\0';
|
||||
handle_ipc_event(msg);
|
||||
close(client_fd);
|
||||
|
||||
FILE *file = fdopen(client_fd, "w");
|
||||
if (!file) {
|
||||
warn("failed to open client as file\n");
|
||||
close(client_fd);
|
||||
} else {
|
||||
handle_ipc_event(file, msg);
|
||||
fclose(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue