GDB (API)
/home/stan/gdb/src/gdb/contrib/expect-read1.c
Go to the documentation of this file.
00001 /* Copyright (C) 2013 Free Software Foundation, Inc.
00002 
00003    This file is part of GDB.
00004 
00005    This program is free software; you can redistribute it and/or modify
00006    it under the terms of the GNU General Public License as published by
00007    the Free Software Foundation; either version 3 of the License, or
00008    (at your option) any later version.
00009 
00010    This program is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013    GNU General Public License for more details.
00014 
00015    You should have received a copy of the GNU General Public License
00016    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
00017 
00018 /* RTLD_NEXT requires _GNU_SOURCE.  */
00019 #define _GNU_SOURCE 1
00020 #include <dlfcn.h>
00021 #include <unistd.h>
00022 #include <fcntl.h>
00023 #include <stdlib.h>
00024 
00025 ssize_t
00026 read (int fd, void *buf, size_t count)
00027 {
00028   static ssize_t (*read2) (int fd, void *buf, size_t count) = NULL;
00029 
00030   if (read2 == NULL)
00031     {
00032       unsetenv ("LD_PRELOAD");
00033       read2 = dlsym (RTLD_NEXT, "read");
00034     }
00035 
00036   if (count > 1 && isatty (fd) == 1)
00037     count = 1;
00038 
00039   return read2 (fd, buf, count);
00040 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines