aboutsummaryrefslogtreecommitdiffstats
path: root/daemon/mutatorserver.c
diff options
context:
space:
mode:
authorbloodstalker <thabogre@gmail.com>2017-03-04 09:48:48 +0000
committerbloodstalker <thabogre@gmail.com>2017-03-04 09:48:48 +0000
commitcc820a1c3c26041b68bf86874e7be2db01b1991e (patch)
tree856627e7c21a8f1a6994c1d15276d713ca323849 /daemon/mutatorserver.c
parentnow uses fgets we don't habe the whitespace problem anymore (diff)
downloadmutator-cc820a1c3c26041b68bf86874e7be2db01b1991e.tar.gz
mutator-cc820a1c3c26041b68bf86874e7be2db01b1991e.zip
now runs a command and returns the output, missing stderr
Diffstat (limited to 'daemon/mutatorserver.c')
-rw-r--r--daemon/mutatorserver.c27
1 files changed, 25 insertions, 2 deletions
diff --git a/daemon/mutatorserver.c b/daemon/mutatorserver.c
index 04e2cd2..c3224d7 100644
--- a/daemon/mutatorserver.c
+++ b/daemon/mutatorserver.c
@@ -23,6 +23,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.*
#include "mutatorserver.h"
/*standard headers*/
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
#include <arpa/inet.h>
#include <unistd.h>
@@ -78,8 +79,30 @@ int main (int argc, char *argv[])
/*recieve a message from client*/
while((read_size = recv(client_sock, client_message, 2000, 0)) > 0)
{
- /*send the message back to the client*/
- write(client_sock, client_message, strlen(client_message));
+ FILE* clientistream;
+ char runresponse[2000];
+#if 0
+ /*get the mutator driver command*/
+ if (system(client_message) < 0)
+ {
+ puts("server returned an error.");
+ }
+#endif
+ /*open pipe, run command*/
+ if (!(clientistream = popen(client_message, "r")))
+ {
+
+ }
+ puts ("task completed.");
+
+ while (fgets(runresponse, sizeof(runresponse), clientistream) != NULL)
+ {
+ write(client_sock, runresponse, strlen(runresponse));
+ }
+ puts("read from temp file.");
+
+ /*close pipe*/
+ pclose(clientistream);
}
if (read_size == 0)