OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2014 The Crashpad Authors. All rights reserved. | |
2 // | |
3 // Licensed under the Apache License, Version 2.0 (the "License"); | |
4 // you may not use this file except in compliance with the License. | |
5 // You may obtain a copy of the License at | |
6 // | |
7 // http://www.apache.org/licenses/LICENSE-2.0 | |
8 // | |
9 // Unless required by applicable law or agreed to in writing, software | |
10 // distributed under the License is distributed on an "AS IS" BASIS, | |
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
12 // See the License for the specific language governing permissions and | |
13 // limitations under the License. | |
14 | |
15 #ifndef CRASHPAD_UTIL_POSIX_CLOSE_STDIO_H_ | |
16 #define CRASHPAD_UTIL_POSIX_CLOSE_STDIO_H_ | |
17 | |
18 namespace crashpad { | |
19 | |
20 //! \brief Closes `stdin` and `stdout` by opening `/dev/null` over them. | |
Robert Sesek
2014/12/19 18:12:05
It may be advisable to mention that is is only saf
| |
21 //! | |
22 //! It is normally inadvisable to `close()` the three standard input/output | |
23 //! streams, because they occupy special file descriptors. Closing them outright | |
24 //! could result in their file descriptors being reused. This causes problems | |
25 //! for library code (including the standard library) that expects these file | |
26 //! descriptors to have special meaning. | |
27 //! | |
28 //! This function discards the standard input and standard output streams by | |
29 //! opening `/dev/null` and assigning it to their file descriptors, closing | |
30 //! whatever had been at those file descriptors previously. | |
31 //! | |
32 //! `stderr`, the standard error stream, is not closed. It is often useful to | |
33 //! retain the ability to send diagnostic messages to the standard error stream. | |
34 void CloseStdinAndStdout(); | |
35 | |
36 } // namespace crashpad | |
37 | |
38 #endif // CRASHPAD_UTIL_POSIX_CLOSE_STDIO_H_ | |
OLD | NEW |