直接将流写出

This commit is contained in:
Pan Qiancheng 2025-04-15 15:28:59 +08:00
parent 605519fde0
commit 9b7908b326
4 changed files with 15 additions and 23 deletions

Binary file not shown.

Binary file not shown.

View File

@ -1,4 +1,4 @@
machine_registry: machine_registry:
endpoint: "http://localhost:9900" endpoint: "http://localhost:3001/endpoint"
log: log:
level: OFF level: OFF

View File

@ -1,11 +1,12 @@
#include "client.h" #include "client.h"
#include <errno.h>
#include <limits.h>
#include <netinet/tcp.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <unistd.h> #include <unistd.h>
#include <errno.h>
#include <limits.h>
#include <netinet/tcp.h>
#define BUFFER_SIZE 4096 #define BUFFER_SIZE 4096
@ -44,7 +45,7 @@ int send_exec_params(const char *filename, char *const argv[],
return -1; return -1;
} }
if (logPath[0] != '/') { // 相对路径 if (logPath[0] != '/') { // 相对路径
size_t pwd_len = strlen(pwd); size_t pwd_len = strlen(pwd);
size_t log_len = strlen(logPath); size_t log_len = strlen(logPath);
if (pwd_len + log_len + 2 > PATH_MAX) { if (pwd_len + log_len + 2 > PATH_MAX) {
@ -161,19 +162,10 @@ int send_exec_params(const char *filename, char *const argv[],
break; break;
} }
// 处理[res]...[wait]消息 strncpy(display_buffer, buffer, BUFFER_SIZE - 1);
char *res_start = strstr(buffer, "[res]"); display_buffer[BUFFER_SIZE - 1] = '\0';
char *wait_end = strstr(buffer, "[wait]"); printf("%s", display_buffer);
fflush(stdout);
if (res_start && wait_end) {
size_t content_len = wait_end - (res_start + strlen("[res]"));
if (content_len < BUFFER_SIZE) {
strncpy(display_buffer, res_start + strlen("[res]"), content_len);
display_buffer[content_len] = '\0';
printf("%s\n", display_buffer);
fflush(stdout);
}
}
} }
close(sock); close(sock);