aboutsummaryrefslogtreecommitdiff
path: root/src/lib/exec.c
diff options
context:
space:
mode:
authorShav Kinderlehrer <[email protected]>2023-05-04 09:59:52 -0400
committerShav Kinderlehrer <[email protected]>2023-05-04 09:59:52 -0400
commitef68f9c37818bd685cf363f67f5c08feb5e21ab0 (patch)
treeaffba5d66641a57e9c398baa987a88e67af58b7b /src/lib/exec.c
parent4618e66f550e7e6b8410fba771345dd4730329f1 (diff)
downloadlat-ef68f9c37818bd685cf363f67f5c08feb5e21ab0.tar.gz
lat-ef68f9c37818bd685cf363f67f5c08feb5e21ab0.zip
Revert extension
Diffstat (limited to 'src/lib/exec.c')
-rw-r--r--src/lib/exec.c63
1 files changed, 2 insertions, 61 deletions
diff --git a/src/lib/exec.c b/src/lib/exec.c
index eb0aebc..4fa98df 100644
--- a/src/lib/exec.c
+++ b/src/lib/exec.c
@@ -9,65 +9,6 @@
#include "util.h"
struct line runextension(struct line *data, char *filename, size_t n) {
- struct line line;
-
- int in[2];
- int out[2];
- if (pipe(out) == -1 || pipe(in) == -1)
- die("pipe");
-
- pid_t pid = fork();
- if (pid == -1)
- die("fork");
-
- if (pid == 0) {
- // child
- dup2(out[1], STDOUT_FILENO);
- close(out[0]);
- close(out[1]);
-
- dup2(in[1], STDIN_FILENO);
- close(in[0]);
- close(in[1]);
-
- char *eargv[4];
- eargv[0] = conf.extension;
- eargv[1] = filename;
- eargv[2] = malloc((intlen(n) + 1) * sizeof(char));
- if (eargv[2] == NULL)
- die("malloc");
- sprintf(eargv[2], "%zu", n);
- eargv[3] = NULL;
-
- if (execvp(conf.extension, eargv) == -1)
- die("exec");
- } else {
- // parent
- close(out[1]);
- close(in[1]);
-
- write(in[0], "test\0", 4);
-
- char *buf = malloc(256);
- memset(buf, '\0', 256);
-
- size_t len = read(out[0], buf, 256);
-
- line.buf = buf;
- line.len = len;
-
- int status;
- waitpid(pid, &status, 0);
-
- if (WEXITSTATUS(status) != EXIT_SUCCESS) {
- die("exec fail");
- }
- }
-
- close(out[0]);
- close(out[1]);
- close(in[0]);
- close(in[1]);
-
- return line;
+ // TODO: Implement as unix socket
+ return *data;
}