Legion 1.4
Developer Manual


6.0 File library interface

The Legion Legion_libBasicFiles.h and link their programs against the library libBasicFiles.a (located in the same directory as the basic Legion libraries). Linkage against the basic Legion libraries is also required.

A sample Legion File Library make file is below.

Figure 14: Sample Legion file library make file
CC       = g++
CFLAGS   = -I$(LEGION)/include -L$(LEGION)/lib/$(LEGION_ARCH)/gnu

include $(LEGION)/src/LibraryCode/macros/$(LEGION_ARCH).$(CC).macros

LIB      = -lBasicFiles -lLegion1 -lLegion2 $(LFLAGS)
 
example: example.c
        $(CC) $(CFLAGS) example.c -o example $(LIB)

This directory contains the Legion basic file objects and libraries for using these objects. Legion basic file objects are quite simple at their core, representing a random-access linear array of bytes.This linear byte array is indexed starting at zero and preceding to (fileSize - s1). Files grow to accommodate the data that are written into them.The random access nature of the basic file object requires clients of the file to maintain their own notion of a file pointer if sequential access is desired. While automatic maintenance of file pointers is not performed by file objects, utility libraries to provide this service are available and are described in Library functions.

6.1 Public methods

The public methods exported by Legion basic files are:

long
write (long startAtByte, BasicFileTransferBlock writeData)

The write method copies a linear array of bytes into the file starting at the location specified by the startAtByte parameter. The data to copy in is transferred in the form of a BasicFileTransferBlock, which contains an integer size field followed by the corresponding number of bytes of data. Write returns the number of bytes actually copied in (for example, a smaller number than requested might be written in case of file size limitations). Writes that are performed at starting locations beyond the offset (fileSize - 1) may be performed, and cause the bytes in the file ranging (inclusive) from offset fileSize through offset (startAtByte - 1) to be set to zero.

BasicFileTransferBlock
read (long startAtByte, long numBytesToRead)

Read returns a copy of the specified linear sub-array of the file starting at the position indicated by the startAtByte parameter and proceeding for numBytesToRead bytes. The read data is returned in the form of a BasicFileTransferBlock (see write above)

BasicFileStatBuffer
stat()

The stat method returns a BasicFileStatBuffer structure containing meta-information about the file object. Currently this structure contains only the file size, but is intended for future expansion.

int
trunc ()

The trunc() method truncates the file size to zero bytes, discarding all data contained in the file. Future writes to the file may once again expand its size, but immediately following the a call to trunc, the file will contain no data.

long
append (BasicFileTransferBlock writeData)

Whereas the write method copies a linear array of bytes to a specified offset within the file, the append method appends a specified array of bytes on to the end of the file, regardless of what offset that may reside at. This method is convenient for use when multiple writers are inserting data into a file object. Whereas use of the write method would require the multiple writers to coordinate a consistent file pointer, the append method allows the multiple writers to write non-overlapping data regions without coordinated file pointers.This method returns the resulting file size (which might be considered the resulting file pointer by the caller).

long
truncAppend (BasicFileTransferBlock writeData)

The truncAppend method atomically truncates the file object to zero bytes, and then appends a linear array of bytes to the file. This method can be used for atomically replacing the entire contents of a file. This action is convenient when a writer and reader are coordinating through the use of a file, and the reader should never be allowed to see an incomplete version of the file. For example, trying to achieve the same effect using the trunc and append methods separately might cause a reader to see an empty file if a read were serviced between the trunc and append. This method returns the number of bytes written (which is equivalent to the resulting file size, and might be considered the resulting file pointer by the caller).

6.2 Library functions

The above interface is somewhat inconvenient in cases where sequential access, and/or frequent, fine-grained access is desirable. To address these issues, a set of library functions is provided to support convenient access to file objects.The interface functions provided with the Legion file library fall into three main categories:

  • Raw, unbuffered I/O
  • Buffered I/O for C and C++
  • Buffered I/O for Fortran
  • The LegionBuffer I/O interface for C++

6.2.1 Raw I/O library

Use of the raw I/O library is supported for programs written in either C or C++. Use of the library requires inclusion of the header legion/Legion_ libBasicFiles.h and linkage against the library libBasicFiles.

The functions supported are as follows.

void
BasicFiles_init

BasicFiles_init initializes the calling object's Legion library state. Note that this function only needs to be called in programs that do not initialize their Legion state in some other way. For example, a Legion-MPI program will have its Legion state initialized by the MPI library, and thus BasicFiles_init need not be called.

void
BasicFiles_done ()

BasicFiles_done disconnects the calling program from Legion. As with BasicFiles_init, this function only needs to be called by programs that do not detach from Legion in some other way (e.g., MPI and PVM programs need not call this function).

int
BasicFiles_exists (char *path)

This function returns a non-zero result if the specified path refers to a valid file object in Legion context space.

BasicFiles_FileDescriptor
BasicFiles_creat (char *path)

BasicFiles_creat creates a new file object, assigning the name specified by path to the new object in context space. Upon success a valid file descriptor is returned. Upon failure the value BasicFiles_BadFd is returned.

BasicFiles_FileDescriptor
BasicFiles_open (char *path, int flags)

BasicFiles_open opens the file object named by path for reading and writing. On success, a valid file descriptor is returned. On failure, the value BasicFiles_BadFd is returned. After an open, the implicit file pointer (i.e. next position for read or write operations on the file) is set to 0. BasicFiles_seek can be used to set the file pointer to alternate locations.
The flags parameter to BasicFiles_open can contain the bitwise inclusive OR of the following values:
BASIC_FILE_O_CREATCreate the file if it does not exist (default action is to return failure).
BASIC_FILE_O_APPENDSpecify that all writes be performed as append operations.
BASIC_FILE_O_TRUNCTruncate the file to zero bytes on successful open.

int
BasicFiles_close (BasicFiles_FileDescriptor fd)

BasicFiles_close closes the file connection associated with fd. Returns -1 upon failure, a non-negative integer upon success.

void
BasicFiles_delete (char *path)

BasicFiles_delete destroys the file object referred to by path. Note that unlike Unix file systems (whose unlink system calls do not interrupt the file service to processes that still have the deleted file open) BasicFiles_delete causes all future file operations performed by other clients to fail.

BasicFiles_FilesOffset
BasicFiles_read (BasicFiles_FileDescriptor fd,
char *data, BasicFiles_FileOffset len)

BasicFiles_read reads up to len bytes of data from the file associated with fd, starting at the current file pointer associated with fd. If the file pointer is at or beyond the end of the file, zero bytes are read. BasicFiles_read returns the actual number of bytes read and copied into data. Upon failure -1 is returned.

BasicFiles_FileOffset
BasicFiles_write (BasicFiles_FileDescriptor fd,
char *data, BasicFiles_FileOffset len)

BasicFiles_write writes up to len bytes of data contained in the buffer data to the file referred to by fd, starting at the current file pointer associated with fd. The actual number of bytes written is returned.

BasicFiles_FileOffset
BasicFiles_seek (BasicFiles_FileDescriptor fd,
BasicFiles_Whence whence, BasicFiles_FileOffset offset)

BasicFiles_seek sets the value of the file pointer associated with fd. The new file pointer location is computed depending on the value of whence:

BASIC_FILE_SEEK_BEGINNINGThe new file pointer is set to offset
BASIC_FILE_SEEK_CURRENTThe new file pointer is set to the old file pointer plus offset.
BASIC_FILE_SEEK_ENDThe new file pointer is the size of the file referred to by fd plus offset.

Note that offset may be negative. Also note that, except in the case of BASIC_FILE_SEEK_END, BasicFiles_seek does not perform remote method invocations (a remote method is required by BASIC_FILE_SEEK_END to compute the file size).
BasicFiles_seek returns the new value of the file pointer associated with fd, or -1 on failure.

BasicFiles_FileOffset
BasicFiles_tell (BasicFiles_FileDescriptor fd)

Returns the current file pointer value associated with fd, or -1 upon failure.

BasicFiles_FileOffset
BasicFiles_size (BasicFiles_FileDescriptor fd)

Returns the current size of the file object associated with fd, or -1 on failure.

BasicFiles_FileOffset
BasicFiles_trunc (BasicFiles_FileDescriptor fd)

Truncates the file object associated with fd to zero bytes and resets the file pointer associated with fd to zero.

BasicFiles_FileOffset
BasicFiles_append (BasicFiles_FileDescriptor fd,
char *data, BasicFiles_FileOffset len)

BasicFiles_append appends up to len bytes of data contained in the buffer data to the end of the file object referred to by fd. The resulting file size is returned on success, -1 upon failure.

BasicFiles_FileOffset
BasicFiles_truncAppend (BasicFiles_FileDescriptor fd,
char *data, BasicFiles_FileOffset len)

Atomically truncates the file referred to by fd to zero bytes, then appends up to len bytes of data contained in the buffer data to that file. The resulting file size is returned on success, -1 upon failure.

6.2.2 Buffered I/O Library, C and C++ Interface

Use of the above raw I/O library can be costly if the user performs frequent, fine-grained file accesses. This results from the need to perform a remote method invocation on each read or write. To provide a more efficient interface for fine-grained accesses, a buffered version of the file library is available.

The functions supported are:

BasicFILE *
BasicFiles_fopen (char *path, char *flags)

Opens the file object names by path for reading and writing. If the file does not exist it is created. Currently, flags is ignored but is reserved for future use--a flags value of NULL will retain the default semantics described here in future versions. On open, the implicit file pointer (location for the next read or write operation) is set to zero. Upon success BasicFiles_fopen returns a non-NULL BasicFILE pointer. Upon failure NULL is returned.

int
BasicFiles_setbufsize (BasicFILE *file, int sz)

Sets the memory buffer size associated with the file referred to by file to sz. The buffer size specifies the maximum amount of data that may be read from or written to the file before an additional remote method invocation is performed. In general, larger buffers can result in better performance but consume more memory. The default buffer size is 8 KB. BasicFiles_setbufsize returns the resulting buffer size upon success, and -1 upon failure.

int
BasicFiles_fclose (BasicFILE *file)

Closes the file associated with file, flushing any pending write operations on the file. Returns a non-negative integer upon success, -1 upon failure.

int
BasicFiles_fflush (BasicFILE *file)

Flushes any pending write operations on the file (i.e., if any data written to the file has been buffered, this function performs the necessary remote method invocations to transfer the data to the actual file object). Returns a non-negative integer upon success, -1 upon failure.

BasicFiles_FileOffset
BasicFiles_fseek (BasicFILE *file, BasicFiles_FileOffset offset,
BasicFiles_Whence whence)

BasicFiles_seek sets the value of the file pointer associated with file. The new file pointer location is computed depending on the value of whence:

BASIC_FILE_SEEK_BEGINNINGThe new file pointer is set to offset.
BASIC_FILE_SEEK_CURRENTThe new file pointer is set to the old file pointer plus offset.
BASIC_FILE_SEEK_END The new file pointer is the size of the file referred to by fd plus offset.

BasicFiles_fseek returns the new value of the file pointer associated with file, or -1 on failure.

BasicFiles_FileOffset
BasicFiles_ftell (BasicFILE *file)

Returns the current file pointer value associated with file, or -1 upon failure.

int
BasicFiles_fputc (int c, BasicFILE *file)

BasicFiles_fputc writes the character c, cast to an unsigned char, to the file referred to by file. Returns the character written as an unsigned char cast to an int upon success, or EOF upon failure.

int
BasicFiles_fputs (char *str, BasicFILE *file)

BasicFiles_fputs writes the null-terminated string str to the file referred to by file at the current file pointer location associated with file. The trailing \0 character is not written (i.e., the call writes strlen(str) bytes). Returns a non-negative integer upon success, -1 upon failure.

int
BasicFiles_fwrite (void *ptr, int size, int nmemb, BasicFILE *file)

BasicFiles_fwrite writes nmemb elements of data contained in the buffer ptr, each size bytes long, to the file referred to by file starting at the current file pointer location associated with file. Returns the number of items (not the number of bytes) successfully written.

int
BasicFiles_fgetc (BasicFILE *file)

BasicFiles_fgetc reads the next character from the file referred to by file and returns it as an unsigned char cast to an int. EOF is returned upon failure.

char *
BasicFiles_fgets (char *str, int sz, BasicFILE *file)

BasicFiles_fgets reads in at most one less than sz characters from the file referred to by file and copies them into the buffer str. Reading stops when the end of file or a newline character is encountered (the terminating newline is copied into str). After either sz-1 characters are read or EOF or newline is encountered, str is terminated with a \0 character. BasicFiles_fgets returns str upon success and NULL upon failure.

int
BasicFiles_fread (void *ptr, int size, int nmemb, BasicFILE *file)

BasicFiles_fread reads nmemb elements of data, each of size bytes, from the file referred to by file, copying the read items into the buffer ptr. BasicFiles_fread returns the number of items (not the number of bytes) successfully read.

6.2.3 Buffered I/O library, Fortran interface

The buffered interface is callable from and well-matched to use in C and C++. However, this library is not conveniently callable nor well-suited for use in Fortran. To better support Legion file access from Fortran programs the following Fortran buffered file interface is provided:

subroutine liof_open (path, flags, fd)
character path(*)
integer flags, fd

Opens the file referred to by the string path for reading and writing. If the file does not exist, it is created. An integer file descriptor is returned in fd, and the file pointer associated with fd is set to zero. Currently flags is ignored but reserved for future use. However, in the future a flags value of 0 will retain the default semantics described here. Upon successful return fd will contain a non-negative integer. Upon failure fd will contain -1.

subroutine liof_close (fd, ret)
integer flags, ret

Closes the file associated with the file descriptor fd. Upon successful return fd will contain 0. Upon failure fd will contain -1.

subroutine liof_write (fd, buf, sz, ret)
integer fd
character buf(*)
integer sz, ret

Writes up to sz bytes of data from the buffer buf to the file referred to by fd starting at the current file pointer associated with fd. Upon successful return ret will contain the number of bytes actually written. Upon failure ret will contain -1.

subroutine liof_write_line (fd, line, sz, ret)
integer fd
character line(*)
integer sz, ret

Writes a formatted line of output contained in the buffer line and spanning no more than sz bytes to the file referred to by fd. The expected use of this routine is for writing a buffer of data created using FORMAT and WRITE Fortran statements to a Legion file. For example:
    character msg*256
10  format(I8,' .... ',I5)
    write(msg,10) X, Y
    call lio_write_line(fd, msg, 256, ret)

subroutine liof_flush (fd, ret)
integer fd, ret

Flushes any pending data writes to the file referred to by fd. Upon successful return ret will contain a non-negative integer. Upon failure ret will contain -1.

subroutine liof_read (fd, buf, sz, ret)
integer fd
character buf(*)
integer sz, ret

Reads up to sz bytes of data from the file referred to by fd into the buffer buf. Upon successful return ret will contain the number of bytes read (zero indicates end of file). Upon failure ret will contain -1.

subroutine liof_read_line (fd, line, sz, ret)
integer fd
character line(*)
integer sz, ret

Reads a line of characters from the file referred to by fd into the buffer line. Up to sz bytes will be read. The resulting data is formatted as acceptable input to the Fortran FORMAT and READ statements. For example:
    character msg*256
10  format(I8,' .... ',I5)
    call lio_read_line(fd, msg, 256, ret)
    read(msg,10) X, Y
Upon successful return, ret will contain a non-negative integer. Upon failure ret will contain -1.

subroutine liof_rewind (fd, ret)
integer fd, ret

Resets the file pointer associated with fd to zero. Upon successful return ret will contain a non-negative integer. Upon failure, ret will contain -1.

subroutine liof_write_ints (fd, x, num, ret)
integer fd
integer x(*)
integer num, ret

Writes num integers from the vector x to the file associated with fd in binary form. Upon return, the number of integer values actually written is returned in ret. Upon failure ret will contain -1.

subroutine liof_read_ints (fd, x, num, ret)
integer fd
integer x(*)
integer num, ret

Reads num integers stored in binary form into the vector x from the file associated with fd. Upon return, the number of integer values actually read is returned in ret. Upon failure, ret will contain -1. Note that platform-dependent data representation issues are masked from the caller (E.g., a caller on a big endian host can read values written by a program on a little endian host).

subroutine liof_write_reals (fd, x, num, ret)
integer fd
real x(*)
integer num, ret

Writes num reals from the vector x to the file associated with fd in binary form. Upon return, the number of real values actually written is returned in ret. Upon failure, ret will contain -1.

subroutine liof_read_reals (fd, x, num, ret)
integer fd
real x(*)
integer num, ret

Reads num reals stored in binary form into the vector x from the file associated with fd. Upon return, the number of real values actually read is returned in ret. Upon failure, ret will contain -1. Note that platform-dependent data representation issues are masked from the caller.

subroutine liof_write_doubles (fd, x, num, ret)
integer fd
double precision x(*)
integer num, ret

Writes num double precision values from the vector x to the file associated with fd in binary form. Upon return, the number of double precision values actually written is returned in ret. Upon failure, ret will contain -1.

subroutine liof_read_doubles (fd, x, num, ret)
integer fd
double precision x(*)
integer num, ret

Reads num double precision values stored in binary form into the vector x from the file associated with fd. Upon return, the number of double precision values actually read is returned in ret. Upon failure, ret will contain -1. Note, platform-dependent data representation issues are masked from the caller.

6.2.4 Buffered I/O library, low impact interface

The object of this interface is to give the user the option of making the smallest number of changes to their program and still use Legion file objects.

If you have an input file, one lio_legion_to_tempfile call is needed. For an output file, the name must first be created using lio_create_tempfile. Then, after the file is written, a single lio_tempfile_to_legion call will write the file to Legion space.

This interface does not allow conversion of the data between different data formats. If you were to write integer values on a RS/6000 and read them on a DEC Alpha, for example, the bytes would be in the wrong order and the DEC would be unable to read them. In order to get full access to Legion's type conversion facilities, the typed binary interface routines such as lio_write_ints must be used.

lio_legion_to_tempfile(character*(*) legion_name,character*(*) tempfile,
integer ierr)

Copies a Legion file object to the local disk. The name of the temporary file created on local disk is a return value and cannot be specified by the application.

lio_create_tempfile(character*(*) tempfile, integer ierr)

Returns the name of a temporary file. To be used with the lio_tempfile_to_legion call (below).

lio_tempfile_to_legion(character*(*) tempfile, character*(*)legion_name,
integer ierr)

Writes a local file into Legion space. The tempfile name is created via the previous function.

6.2.5 The LegionBuffer I/O interface

The C and C++ interfaces described in 6.2.1 and 6.2.2 are similar to typical system-call level and C standard I/O level file interfaces.

A potentially more convenient and useful interface is available for C++ programs--the LegionBuffer interface. The LegionBuffer is the basic data container supported by the Legion library. The standard Legion library supports LegionBuffer implementations for in-memory buffers, and Unix file buffers. The Legion basic file libraries add on a new LegionBuffer implementation that can be used to access Legion file objects.

Use of the new LegionBuffer type is simple:

  • Include the header file Legion_BasicFiles.h
  • Call the new utility function
UVaL_Reference BasicFiles_openBuffer(char *path);

This function returns a LegionBuffer that can be used to access the file object referred to by path. If no such file exists, it is created.

The standard LegionBuffer interface is described in section 7.2, "Basic module and data container: the Legion buffer."

6.3 Terminal I/O

When objects run in the Legion system, they execute on remote hosts. Thus (in the default case), their output (e.g. printfs, writes to stderr, fortran writes to unit 6, etc.) is not visible in the terminal where the main program was started. This situation can make debugging, porting existing code, and many other problems extremely difficult. To address this, the Legion file library supports mechanisms to allow remote objects to use terminal output. The interface to these mechanisms is presented in this section. Note that this interface is run automatically in PVM and MPI, and that there is a similar, smaller, set of routines that can be run in Fortran (see below). The basic operation of these mechanisms is based on the use of tty objects, which are objects to which output from remote programs can be directed and from which this output can be obtained and displayed on the screen.

6.3.1 Library interface

The library interface supports two basic styles of performing terminal I/O, each with different features, costs, and benefits.

  • The first interface supports explicit library calls to perform terminal output. This mechanism has the advantage of dynamic updates of the current active terminal object as methods are performed. In other words, if a method is called, for which the caller requires output to one terminal, and then a second method is called, for which the caller requires output to a second terminal, the caller can use the explicit library interface to automatically assure that output from the object is sent to the appropriate location. The disadvantage of this approach is that it requires explicit changes to user code wherever output is required. That is, every printf must be manually changed to a legion_printf. This may be infeasible in large legacy codes.

  • The second interface supports the mapping of the object's native standard output and standard error to a Legion terminal object. This mechanism has the advantage of requiring very little code modification. However, once standard output is mapped it must be explicitly unmapped and then remapped on method boundaries of multiple callers. Terminal locations are to be respected. This drawback may not be an issue for some applications. For example, if a set of objects is created for a single application run by a single user the output will always be directed a single terminal object.

Both of these styles may be combined arbitrarily. In order to operate the library interface, run-time support in the form of tty objects must be created (explained in "About Legion tty objects"in the Basic User Manual).

The interface for explicit terminal I/O consists of the following functions:

int
legion_tty_init() ;

This function should be called before any method invocations on remote objects that will perform legion terminal output. It sets up the required library environment to direct output from remote objects to the current tty object for the calling program. Returns 0 on success, -1 on error. An error return indicates that no tty object is set in the callers environment, and thus remote output will not be directed.

int
legion_tty_write (char *buf, int n);

Writes n bytes contained in the buffer buf to the current tty object set in the callers environment. Returns the number of bytes written, or -1 on error.

int
legion_puts (char *s);

Writes the null terminates string starting at s to the current tty object set in the callers environment. Returns the number of bytes written, or -1 on error.

int
legion_printf (char *format, ...);

Performs formatted I/O in the style of the standard C library function printf. Output is directed to the current tty object set in the callers environment. See the man page for printf for an explanation of the format string.

The interface for the implicit terminal I/O mechanism consists of the following functions:

int
legion_map_stdio();

This function can be called by a Legion object to map native standard output and standard error (i.e. file descriptors 1 and 2) to the current tty object set in the callers environment. All future writes to stdout and stderr will be mapped to the tty object, until legion_unmap_stdio is called. Note that if the current standard output file descriptor is attached to a terminal this call has no effect. It can thus safely be called by objects that will sometimes operate from the command line and sometimes act as remote objects.
Returns 0 on success, -1 if no tty object is available in the caller's environment.

int
legion_unmap_stdio ();

Disconnects standard output from the current tty object. Note that legion_unmap_stdio must be called between successive calls to legion_map_stdio in order to map standard output to different tty objects.
Returns -1 if standard output is not currently connected to a tty object, 0 on success.

int
legion_register_tty_callback (void (*callback)(char *, long));

This library routine can be called to register a function that will be used to observe output written to the tty object that is currently set in the caller's environment. As data is written to the tty object, the callback specified by this function will be invoked. Each invocation will be passed the length of the data as well as a pointer to the new data. By using this function an object can asynchronously observe the data written to the current terminal object. Note that the interface allows only a single registered callback in a single Legion object, although any number of Legion objects can use this function to observe the same tty object (all data is sent to all registered observers).
Returns 0 on success, -1 if no tty object is set in the current environment.

int
legion_watch_stdio ();

Whereas legion_register_tty_callback allows a caller to process the data written to a tty object arbitrarily, legion_watch_stdio performs the common-case action of mapping the current tty object's output to the caller's standard output. After this function is called, any data written to the current tty object will be copied to the standard output of the caller. For example, this function might be called at the beginning of the master process so that the output from all of its slaves will be mapped to its own standard output.
Returns 0 on success, -1 if no tty object is set in the current environment.
WARNING: legion_watch_stdio is completely asynchronous. If objects (e.g., children of the caller) perform output after the caller has exited, the output will not be displayed to the caller's terminal.

int
legion_disconnect_stdio ();

This call unregisters the current callback if one was specified by legion_register_tty_callback, or disconnects the current tty from the callers standard output if it was connected using legion_watch_stdio.
Returns 0 on success, -1 on failure.

Some of the above routines can be called from Fortran. The interface is listed below:

subroutine legionf_tty_init (ret)
integer ret
subroutine legionf_map_stdio (ret)
integer ret
subroutine legionf_unmap_stdio (ret)
integer ret
subroutine legionf_watch_stdio (ret)
integer ret
subroutine legionf_disconnect_stdio (ret)
integer ret

In all cases, the return code of the routine (as described for the C interface above) is stored in ret.

6.3.2 Command-line tools

For the Legion terminal output mechanisms to operate correctly, runtime support in the form of tty objects is created (tty objects are discussed in more detail on "About Legion tty objects" in the Basic User Manual). There are two ways to set up this runtime support:

  1. The standard Legion command legion_tty creates, sets, and watches tty objects. For example:
  2. legion_tty my_stdio
    The name my_stdio is a Legion context name, and can be any name selected by the user. Use legion_tty_off to exit.

  3. Or, you can use a separate command for each step. The legion_create_object command can be used to create a tty object.
    legion_create_object -c /class/ttyObjectClass my_stdio
    The legion_set_tty command will set a previously created tty object. The syntax is:
    legion_set_tty <context name>
    For example, to set the tty object created in step 1 (above) as the tty object for Legion programs you will run in the current shell, execute:
    legion_set_tty my_stdio
    You can watch the current tty object set in your shell and observe the data written to it using the legion_tty_watch command. This command attaches to the current tty object and displays its output. The command is blocking: use ctrl-C to exit.


Back to Developer Manual Table of Contents