Unverified Commit f705f4a5 authored by Dapa's avatar Dapa Committed by GitHub

Update service.cpp

parent 8ba2034c
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h> #include <unistd.h>
#include <sys/wait.h> #include <sys/wait.h>
#include <string> #include <string.h>
using namespace std; using namespace std;
...@@ -11,11 +11,22 @@ int command(const char *cmd) { ...@@ -11,11 +11,22 @@ int command(const char *cmd) {
if ((pid = fork())) { if ((pid = fork())) {
waitpid(pid, &status, 0); waitpid(pid, &status, 0);
} else { } else {
execl("/bin/bash", "/bin/bash", "-c", cmd, NULL); char *env = new char[2048]; // fingers crossed this is enough
strcpy(env, "PATH=");
strcat(env, getenv("PATH"));
strcat(env, ":");
strcat(env, getenv("HOME"));
strcat(env, "/.virtualenv/bin");
env[strlen(env)+1] = '\0';
execl("/bin/bash", "/bin/bash", "-c", cmd, NULL, env);
} }
return status; return status;
} }
int main() { int main() {
cout << command("cd ~/.virtualenv/bin && PATH=$(pwd):$PATH && python3") << std::endl; while(1)
{
command("timeout 15m python3");
sleep(300);
}
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment