Mercurial > octave
diff liboctave/oct-syscalls.cc @ 10259:65b41bc71f09
use gnulib fcntl module
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 03 Feb 2010 17:05:02 -0500 |
parents | 0522a65bcd56 |
children | 07ebe522dac2 |
line wrap: on
line diff
--- a/liboctave/oct-syscalls.cc Wed Feb 03 15:27:53 2010 -0500 +++ b/liboctave/oct-syscalls.cc Wed Feb 03 17:05:02 2010 -0500 @@ -33,9 +33,7 @@ #include <sys/types.h> #include <unistd.h> -#ifdef HAVE_FCNTL_H #include <fcntl.h> -#endif // We can't use csignal as kill is not in the std namespace, and picky // compiler runtimes will also exclude it from global scope as well. @@ -113,35 +111,6 @@ return status; } -int -octave_syscalls::fcntl (int fd, int cmd, long arg) -{ - std::string msg; - return fcntl (fd, cmd, arg, msg); -} - -int -octave_syscalls::fcntl (int fd, int cmd, long arg, std::string& msg) -{ - msg = std::string (); - - int status = -1; - -#if defined (HAVE_FCNTL) - status = ::fcntl (fd, cmd, arg); - - if (status < 0) - { - using namespace std; - msg = ::strerror (errno); - } -#else - msg = NOT_SUPPORTED ("fcntl"); -#endif - - return status; -} - pid_t octave_syscalls::fork (std::string& msg) { @@ -422,7 +391,7 @@ ::close (child_stdin[0]); ::close (child_stdout[1]); #if defined (F_SETFL) && defined (O_NONBLOCK) - if (! sync_mode && fcntl (child_stdout[0], F_SETFL, O_NONBLOCK, msg) < 0) + if (! sync_mode && octave_fcntl (child_stdout[0], F_SETFL, O_NONBLOCK, msg) < 0) msg = "popen2: error setting file mode -- " + msg; else #endif @@ -446,3 +415,28 @@ return -1; #endif } + +int +octave_fcntl (int fd, int cmd, long arg) +{ + std::string msg; + return octave_fcntl (fd, cmd, arg, msg); +} + +int +octave_fcntl (int fd, int cmd, long arg, std::string& msg) +{ + msg = std::string (); + + int status = -1; + + status = ::fcntl (fd, cmd, arg); + + if (status < 0) + { + using namespace std; + msg = ::strerror (errno); + } + + return status; +}