agent: add signal handlers

This commit is contained in:
2019-01-13 12:26:15 +02:00
parent 77947d17e5
commit fe354d9f74
2 changed files with 72 additions and 14 deletions

View File

@@ -104,17 +104,20 @@ void* get_os(void *args)
system(cmd); /* TODO: set proper path */
if ((fd = open(dump_path, O_RDONLY)) == -1) {
fprintf(stderr, "Cannot open file: %s\n", dump_path);
job->buf.meta.len = sprintf((char*)job->buf.chunk.data, "Unknown");
SSL_write(job->ssl, &job->buf, sizeof(struct msg_t));
job->buf.meta.len = sprintf((char*)job->buf.chunk.data,
"I/O error");
//SSL_write(job->ssl, &job->buf, sizeof(struct msg_t));
} else {
job->buf.meta.len = read(fd, job->buf.chunk.data, sizeof(job->buf.chunk.data));
if ((signed)job->buf.meta.len == -1) {
perror("Failed to read from file: ");
}
close(fd);
SSL_write(job->ssl, &job->buf, sizeof(struct msg_t));
job->slot = FREE;
//SSL_write(job->ssl, &job->buf, sizeof(struct msg_t));
//job->slot = FREE;
}
SSL_write(job->ssl, &job->buf, sizeof(struct msg_t));
job->slot = FREE;
unlink(dump_path);
return 0;
}