pty (program, arguments...? = nil) ptytio (termios, program, arguments...? = nil)
A string containing the name of the program to be executed.
A string containing any command-line arguments for the program.
A termios structure.
A list of:
(process_id file_for_stdin file_for_stdout file_for_stderr pty_name)
Where:
The process ID of the program called.
A pointer to the file used for STDIN.
A pointer to the file used for STDOUT.
A pointer to the file used for STDERR.
The 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 info@cogent.ca." Gamma> read_line(caddr(ptylist)); "Test output." Gamma> read_line(caddr(ptylist)); "Argument" Gamma>
Copyright © 1995-2010 by Cogent Real-Time Systems, Inc. All rights reserved.