pty, ptytio
pty, ptytio — run programs in a pseudo-tty.
pty (program, arguments...? = nil)
ptytio (termios, program, arguments...? = nil)
programA string containing the name of the program to be executed.
argumentsA string containing any command-line arguments for the program.
termiosA termios
structure.
A list of:
(process_idfile_for_stdinfile_for_stdoutfile_for_stderrpty_name)
Where:
process_idThe process ID of the program called.
file_for_stdinA pointer to the file used for STDIN.
file_for_stdoutA pointer to the file used for STDOUT.
file_for_stderrA pointer to the file used for STDERR.
pty_nameThe path and filename of this pseudo-tty, as a string.
These functions run programs in a pseudo-tty. A Gamma program can read
from either program's standard output by issuing a read
or read_line call on
file_for_stdout. The process can be reaped
using wait.
The ptytio function is the same as
pty, but the first argument is a termios structure. This is useful if
particular terminal characteristics are required on the
pty. The termios structure is only available through the
gammatios.so dynamic library.
This example calls pty on the following test program,
called testpty.g:
#!/usr/cogent/bin/gamma
princ("Test output.\n");
princ(cadr(argv),"\n");
Here we call pty in interactive mode, and then read
the output:
Gamma>ptylist = pty("testpty.g", "Argument");(4760 #<File:"testpty.g-stdin"> #<File:"testpty.g-stdout"> #<File:"testpty.g-stderr"> "/dev/ptyp0")Gamma>read_line(caddr(ptylist));"This software is free for non-commercial use, and no valid commercial license"Gamma>read_line(caddr(ptylist));"is installed. For more information, please contact [email protected]."Gamma>read_line(caddr(ptylist));"Test output."Gamma>read_line(caddr(ptylist));"Argument"Gamma>