GNU Octave  4.2.1
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
wait-for-input.c
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 2016-2017 John W. Eaton
4 
5 This file is part of Octave.
6 
7 Octave is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the
9 Free Software Foundation; either version 3 of the License, or (at your
10 option) any later version.
11 
12 Octave is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
16 
17 You should have received a copy of the GNU General Public License
18 along with Octave; see the file COPYING. If not, see
19 <http://www.gnu.org/licenses/>.
20 
21 */
22 
23 // select may be provided by gnulib. We don't include gnulib headers
24 // directly in Octave's C++ source files to avoid problems that may be
25 // caused by the way that gnulib overrides standard library functions.
26 
27 // We don't need select directly, we just need to use it to wait for
28 // input on an open file descriptor.
29 
30 #if defined (HAVE_CONFIG_H)
31 # include "config.h"
32 #endif
33 
34 #include <sys/select.h>
35 
36 #include "wait-for-input.h"
37 
38 int
40 {
41  int retval = -1;
42 
43 #if defined (HAVE_SELECT)
44  if (fid >= 0)
45  {
46  fd_set set;
47 
48  FD_ZERO (&set);
49  FD_SET (fid, &set);
50 
51  retval = select (FD_SETSIZE, &set, 0, 0, 0);
52  }
53 #else
54  retval = 1;
55 #endif
56 
57  return retval;
58 }
octave_value retval
Definition: data.cc:6294
int octave_wait_for_input(int fid)
set(hf,"paperorientation") esult
Definition: graphics.cc:10111