003 File Manager
Current Path:
/usr/src/contrib/xz/src/common
usr
/
src
/
contrib
/
xz
/
src
/
common
/
📁
..
📄
mythread.h
(11.77 KB)
📄
sysdefs.h
(4.8 KB)
📄
tuklib_common.h
(1.86 KB)
📄
tuklib_config.h
(121 B)
📄
tuklib_cpucores.c
(2.3 KB)
📄
tuklib_cpucores.h
(606 B)
📄
tuklib_exit.c
(1.51 KB)
📄
tuklib_exit.h
(706 B)
📄
tuklib_gettext.h
(1.04 KB)
📄
tuklib_integer.h
(16.67 KB)
📄
tuklib_mbstr.h
(2.81 KB)
📄
tuklib_mbstr_fw.c
(745 B)
📄
tuklib_mbstr_width.c
(1.48 KB)
📄
tuklib_open_stdxxx.c
(1.43 KB)
📄
tuklib_open_stdxxx.h
(647 B)
📄
tuklib_physmem.c
(5.65 KB)
📄
tuklib_physmem.h
(763 B)
📄
tuklib_progname.c
(1.11 KB)
📄
tuklib_progname.h
(817 B)
Editing: tuklib_open_stdxxx.c
/////////////////////////////////////////////////////////////////////////////// // /// \file tuklib_open_stdxxx.c /// \brief Make sure that file descriptors 0, 1, and 2 are open // // Author: Lasse Collin // // This file has been put into the public domain. // You can do whatever you want with this file. // /////////////////////////////////////////////////////////////////////////////// #include "tuklib_open_stdxxx.h" #ifndef TUKLIB_DOSLIKE # include <stdlib.h> # include <errno.h> # include <fcntl.h> # include <unistd.h> #endif extern void tuklib_open_stdxxx(int err_status) { #ifdef TUKLIB_DOSLIKE // Do nothing, just silence warnings. (void)err_status; #else for (int i = 0; i <= 2; ++i) { // We use fcntl() to check if the file descriptor is open. if (fcntl(i, F_GETFD) == -1 && errno == EBADF) { // With stdin, we could use /dev/full so that // writing to stdin would fail. However, /dev/full // is Linux specific, and if the program tries to // write to stdin, there's already a problem anyway. const int fd = open("/dev/null", O_NOCTTY | (i == 0 ? O_WRONLY : O_RDONLY)); if (fd != i) { if (fd != -1) (void)close(fd); // Something went wrong. Exit with the // exit status we were given. Don't try // to print an error message, since stderr // may very well be non-existent. This // error should be extremely rare. exit(err_status); } } } #endif return; }
Upload File
Create Folder