Example #1
0
        /// <summary>
        /// Sends a request to the pseudo terminal to set the size to the specified one
        /// </summary>
        /// <param name="fd">File descriptor returned by ForkPty</param>
        /// <param name="winSize">The desired window size</param>
        /// <returns></returns>
        public static int SetWinSize(int fd, ref UnixWindowSize winSize)
        {
            const long MAC_TIOCSWINSZ = 0x80087467;
            var        r = ioctl(fd, MAC_TIOCSWINSZ, ref winSize);

            if (r == -1)
            {
                var lastErr = Marshal.GetLastWin32Error();
                Console.WriteLine(lastErr);
            }
            return(r);
        }
Example #2
0
 extern static int ioctl(int fd, long cmd, ref UnixWindowSize WinSz);
Example #3
0
 extern static int HeavyFork(string process, string [] args, string [] env, out int master, UnixWindowSize winSize);
Example #4
0
        /// <summary>
        /// Forks a process and returns a file handle that is connected to the standard output of the child process
        /// </summary>
        /// <param name="programName">Name of the program to run</param>
        /// <param name="args">Argument to pass to the program</param>
        /// <param name="env">Desired environment variables for the program</param>
        /// <param name="master">The file descriptor connected to the input and output of the child process</param>
        /// <param name="winSize">Desired window size</param>
        /// <returns></returns>
        public static int ForkAndExec(string programName, string [] args, string [] env, out int master, UnixWindowSize winSize)
        {
            if (HeavyDuty)
            {
                return(HeavyFork(programName, args, env, out master, winSize));
            }
            else
            {
                var pid = forkpty(out master, IntPtr.Zero, IntPtr.Zero, ref winSize);
                if (pid < 0)
                {
                    throw new Exception("Could not create Pty");
                }

                if (pid == 0)
                {
                    execve(programName, args, env);
                }
                return(pid);
            }
        }
Example #5
0
 extern static int forkpty(out int master, IntPtr dataReturn, IntPtr termios, ref UnixWindowSize WinSz);