c++.idde - _O_NOINHERIT
- Riccardo Cohen (36/36) Nov 19 2003 Hi,
- Arjan Knepper (5/22) Nov 19 2003 How is _open() implemented in the metakit lib? With CreateFile ? The 128...
- Riccardo Cohen (16/42) Nov 19 2003 Thanks for your quick answer.
- Arjan Knepper (9/48) Nov 19 2003 OK you are just using the c-runtime '_open (..)'.
- Riccardo Cohen (14/69) Nov 20 2003 I found that _open() function is defined as open(), but could not find o...
Hi, I use metakit library, and in a call to "_open()" they use flag _O_NOINHERIT This flag is not documented (could not find in winhelp), but it exists and is set to 128 (I made a printf). When running the code below, the file is not created. I have to remove the flag, then it works. (DigitalMars compiler (8.37) ) With MS DevStudio the flag is also set to 128 but that does not change behavior and the file is created. I would like to know if this is a bug or if there is something I dont understand. Thanks -- Riccardo Cohen Articque Les Roches 37230 Fondettes France web = http://www.articque.com tel: +33 02 47 49 90 49 fax: +33 02 47 49 91 49 ======================================================== #include <io.h> #include <fcntl.h> #include <sys/stat.h> #include <stdio.h> int main() { printf("%d\n",_O_NOINHERIT); int flags = _O_BINARY | _O_NOINHERIT | _O_RDWR ; int fd = _open("d:\\zdrop\\testfile.out", flags | _O_CREAT, _S_IREAD | _S_IWRITE); if (fd!=1) { _write (fd,"ok",2); _close(fd); } char tmp[100]; gets(tmp); return(0); }
Nov 19 2003
How is _open() implemented in the metakit lib? With CreateFile ? The 128 (decimal) == 80(hex) == FILE_ATTRIBUTE_NORMAL which is the only exclusive flag for the file attribute arg in CreateFile. Arjan Riccardo Cohen wrote:Hi, I use metakit library, and in a call to "_open()" they use flag _O_NOINHERIT This flag is not documented (could not find in winhelp), but it exists and is set to 128 (I made a printf). When running the code below, the file is not created. I have to remove the flag, then it works. (DigitalMars compiler (8.37) ) With MS DevStudio the flag is also set to 128 but that does not change behavior and the file is created. I would like to know if this is a bug or if there is something I dont understand. Thanks
Nov 19 2003
Thanks for your quick answer. The code is : int flags = _O_BINARY | _O_NOINHERIT | (mode_ > 0 ? _O_RDWR : _O_RDONLY); int fd = _open(fname_, flags); I dont really understand your question. _open() is not implemented by metakit library, but by win32sdk. The function CreateFile is not called by the metakit library. Arjan Knepper wrote:How is _open() implemented in the metakit lib? With CreateFile ? The 128 (decimal) == 80(hex) == FILE_ATTRIBUTE_NORMAL which is the only exclusive flag for the file attribute arg in CreateFile. Arjan Riccardo Cohen wrote:-- Riccardo Cohen Articque Les Roches 37230 Fondettes France web = http://www.articque.com tel: +33 02 47 49 90 49 fax: +33 02 47 49 91 49Hi, I use metakit library, and in a call to "_open()" they use flag _O_NOINHERIT This flag is not documented (could not find in winhelp), but it exists and is set to 128 (I made a printf). When running the code below, the file is not created. I have to remove the flag, then it works. (DigitalMars compiler (8.37) ) With MS DevStudio the flag is also set to 128 but that does not change behavior and the file is created. I would like to know if this is a bug or if there is something I dont understand. Thanks
Nov 19 2003
OK you are just using the c-runtime '_open (..)'. Take a look at the source file which implements _open (..) in the compiler src directory. That way you can see how the _O_NOINHERIT is affecting the file open api call (which will probably use CreateFile). I would not use the "undocumented" _O_NOINHERIT. Has problaby something to do with the HANDLE returned from CreateFile not being inheritable by child processes or threads or DuplicateHandle. Arjan Riccardo Cohen wrote:Thanks for your quick answer. The code is : int flags = _O_BINARY | _O_NOINHERIT | (mode_ > 0 ? _O_RDWR : _O_RDONLY); int fd = _open(fname_, flags); I dont really understand your question. _open() is not implemented by metakit library, but by win32sdk. The function CreateFile is not called by the metakit library. Arjan Knepper wrote:How is _open() implemented in the metakit lib? With CreateFile ? The 128 (decimal) == 80(hex) == FILE_ATTRIBUTE_NORMAL which is the only exclusive flag for the file attribute arg in CreateFile. Arjan Riccardo Cohen wrote:Hi, I use metakit library, and in a call to "_open()" they use flag _O_NOINHERIT This flag is not documented (could not find in winhelp), but it exists and is set to 128 (I made a printf). When running the code below, the file is not created. I have to remove the flag, then it works. (DigitalMars compiler (8.37) ) With MS DevStudio the flag is also set to 128 but that does not change behavior and the file is created. I would like to know if this is a bug or if there is something I dont understand. Thanks
Nov 19 2003
I found that _open() function is defined as open(), but could not find open() except in IOS/FILESYS.H definition. Anyway I understand that this undocumented flag should not be used. Thanks for the info. Arjan Knepper wrote:OK you are just using the c-runtime '_open (..)'. Take a look at the source file which implements _open (..) in the compiler src directory. That way you can see how the _O_NOINHERIT is affecting the file open api call (which will probably use CreateFile). I would not use the "undocumented" _O_NOINHERIT. Has problaby something to do with the HANDLE returned from CreateFile not being inheritable by child processes or threads or DuplicateHandle. Arjan Riccardo Cohen wrote:-- Riccardo Cohen Articque Les Roches 37230 Fondettes France web = http://www.articque.com tel: +33 02 47 49 90 49 fax: +33 02 47 49 91 49Thanks for your quick answer. The code is : int flags = _O_BINARY | _O_NOINHERIT | (mode_ > 0 ? _O_RDWR : _O_RDONLY); int fd = _open(fname_, flags); I dont really understand your question. _open() is not implemented by metakit library, but by win32sdk. The function CreateFile is not called by the metakit library. Arjan Knepper wrote:How is _open() implemented in the metakit lib? With CreateFile ? The 128 (decimal) == 80(hex) == FILE_ATTRIBUTE_NORMAL which is the only exclusive flag for the file attribute arg in CreateFile. Arjan Riccardo Cohen wrote:Hi, I use metakit library, and in a call to "_open()" they use flag _O_NOINHERIT This flag is not documented (could not find in winhelp), but it exists and is set to 128 (I made a printf). When running the code below, the file is not created. I have to remove the flag, then it works. (DigitalMars compiler (8.37) ) With MS DevStudio the flag is also set to 128 but that does not change behavior and the file is created. I would like to know if this is a bug or if there is something I dont understand. Thanks
Nov 20 2003