Browse Source

调整代码格式

master
453530270@qq.com 2 years ago
parent
commit
9166a7a159
  1. 4
      client.c

4
client.c

@ -132,6 +132,7 @@ int rcopy_client(char *src, char *host, unsigned short port, char *r_src, int ty
exit(1); exit(1);
} }
// 发送文件
if (r.type == TRANSFILE) { if (r.type == TRANSFILE) {
FILE *out; FILE *out;
if ((out = fopen(src, "rb")) != NULL) { if ((out = fopen(src, "rb")) != NULL) {
@ -147,6 +148,7 @@ int rcopy_client(char *src, char *host, unsigned short port, char *r_src, int ty
} }
} }
// 读取socket数据
int status, len; int status, len;
len = read(sockfd, &status, sizeof(int)); len = read(sockfd, &status, sizeof(int));
if (len != sizeof(int)) { if (len != sizeof(int)) {
@ -154,6 +156,7 @@ int rcopy_client(char *src, char *host, unsigned short port, char *r_src, int ty
exit(1); exit(1);
} else { } else {
if (status == SENDFILE) { if (status == SENDFILE) {
// 获取pid
pid_t pid = fork(); pid_t pid = fork();
if (pid == 0) { if (pid == 0) {
close(sockfd); // child will initate a new connection. close(sockfd); // child will initate a new connection.
@ -207,6 +210,7 @@ int rcopy_client(char *src, char *host, unsigned short port, char *r_src, int ty
while (fcalls > 0) { while (fcalls > 0) {
wait(&status); wait(&status);
if (WIFEXITED(status)) { if (WIFEXITED(status)) {
// 从子进程的终止状态中提取出退出状态码
pid = WEXITSTATUS(status); pid = WEXITSTATUS(status);
if (!final) { if (!final) {
final = pid; final = pid;

Loading…
Cancel
Save