|
|
|
@ -2,7 +2,9 @@
|
|
|
|
|
#include <fcntl.h>
|
|
|
|
|
#include <unistd.h>
|
|
|
|
|
#include <cstring>
|
|
|
|
|
#ifdef __LINUX__
|
|
|
|
|
#include <sys/wait.h>
|
|
|
|
|
#endif
|
|
|
|
|
#include <string>
|
|
|
|
|
#include <memory>
|
|
|
|
|
|
|
|
|
@ -12,10 +14,12 @@ private:
|
|
|
|
|
int from_shell[2];
|
|
|
|
|
pid_t shell_pid;
|
|
|
|
|
|
|
|
|
|
#ifdef __LINUX__
|
|
|
|
|
void setNonBlocking(int fd) {
|
|
|
|
|
int flags = fcntl(fd, F_GETFL, 0);
|
|
|
|
|
fcntl(fd, F_SETFL, flags | O_NONBLOCK);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
void writeCommand(const std::string& command) {
|
|
|
|
|
write(to_shell[1], command.c_str(), command.length());
|
|
|
|
|