RAD Studio |  |

Passing File Information To Child Processes
See Also
Collapse All

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 read-only access in binary mode, and then spawns a child process, the child process might corrupt the file by writing to it, or by reading from 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:

Copy Code

    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

The main() Function

execl

spawnl

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!