#include <ctype.h>
#include <win.h>
+static int ShellFD;
+
#define INCLUDE_DEFS
#include "config.h"
}
#ifndef TEST
+#include <unistd.h>
+#include <util.h>
+#include <sys/ioctl.h>
+
+void spawn_shell(int master, int slave) {
+ static char* shell[] = { "/bin/sh", "-l", NULL };
+ dup2(slave, 0);
+ dup2(slave, 1);
+ dup2(slave, 2);
+ if (ioctl(slave, TIOCSCTTY, NULL) < 0)
+ die("ioctl(TIOSCTTY) failed");
+ close(slave);
+ close(master);
+ execvp(shell[0], shell);
+}
+
int main(int argc, char** argv) {
+ int pid, m, s;
+ if (openpty(&m, &s, NULL, NULL, NULL) < 0)
+ die("openpty failed: %s\n", strerror(errno));
+ if ((pid = fork()))
+ die("fork failed");
+
+ if (pid == 0) {
+ spawn_shell(m, s);
+ } else {
+ close(s);
+ ShellFD = m;
+ //signal(SIGCHLD, sigchld);
+ }
+
win_window("term", onerror);
//win_setkeys(&Bindings);
//win_setmouse(&MouseHandlers);
win_loop();
+
return 0;
}
#endif