Skip to content

Commit

Permalink
improve output
Browse files Browse the repository at this point in the history
  • Loading branch information
st0nie committed Apr 9, 2024
1 parent f4b5c7b commit 15f5a50
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 12 deletions.
28 changes: 18 additions & 10 deletions extra/service/legiond/legiond-ctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,6 @@ int main(int argc, char *argv[])
exit(1);
}

// init socket
int fd = socket(AF_UNIX, SOCK_STREAM, 0);
struct sockaddr_un addr;
addr.sun_family = AF_UNIX;
strcpy(addr.sun_path, socket_path);
int ret = connect(fd, (struct sockaddr *)&addr, sizeof(addr));
if (ret == -1) {
exit(-1);
}
char request[20] = "";

if (argc > 1) {
Expand All @@ -32,8 +23,25 @@ int main(int argc, char *argv[])
sprintf(request, "B"); // B means cpuset
} else if (strcmp(argv[1], "reload") == 0) {
sprintf(request, "R"); // R means reload config
} else {
printf("unknown arguments\n");
exit(1);
}
}
send(fd, request, strlen(request), 0);

// init socket
int fd = socket(AF_UNIX, SOCK_STREAM, 0);
struct sockaddr_un addr;
addr.sun_family = AF_UNIX;
strcpy(addr.sun_path, socket_path);

if (connect(fd, (struct sockaddr *)&addr, sizeof(addr)) == -1) {
exit(2);
}

if (send(fd, request, strlen(request), 0) != -1) {
printf("successfully sent cmd\n");
}

close(fd);
}
3 changes: 1 addition & 2 deletions extra/service/legiond/legiond.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,8 @@ int main()
struct sockaddr_un addr;
addr.sun_family = AF_UNIX;
strcpy(addr.sun_path, socket_path);
int ret = bind(fd, (struct sockaddr *)&addr, sizeof(addr));

if (ret == -1) {
if (bind(fd, (struct sockaddr *)&addr, sizeof(addr)) == -1) {
exit(1);
}

Expand Down

0 comments on commit 15f5a50

Please sign in to comment.