pty (program, arguments...? = nil) ptytio (termios, program, arguments...? = nil)
A list of:
(process_id file_for_stdin file_for_stdout file_for_stderr pty_name)
Where:
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 info@cogent.ca."
Gamma> read_line(caddr(ptylist));
"Test output."
Gamma> read_line(caddr(ptylist));
"Argument"
Gamma>
Copyright © 1995-2012 by Cogent Real-Time Systems, Inc. All rights reserved.