Passing File Information To Child Processes

From RAD Studio
Jump to: navigation, search

Go Up to C Run-Time Library Reference

If your program uses the exec or spawn functions to create a new process, the new process will normally inherit all of the open file handles created by the original process. Some information, however, about these handles will be lost, including the access mode used to open the file. For example, if your program opens a file for append in binary mode the child process may corrupt the file by writing at a location other than the end-of-file or by writing to it in text mode.

To allow child processes to inherit such information about open files, you must link your program with the object file FILEINFO.OBJ.

For example:

BCC32 TEST.C \BCB\LIB\FILEINFO.OBJ

The file information is passed in the environment variable _C_FILE_INFO. This variable contains encoded binary information. Your program should not attempt to read or modify its value. The child program must have been built with the C++ runtime library to inherit this information correctly.

Other programs can ignore _C_FILE_INFO, and will not inherit file information.

See Also