Mercurial > hg > octave-nkf
annotate libinterp/corefcn/syscalls.cc @ 18189:d638db6d045c stable
doc: Note that dbstop can be used with class methods as well (bug #40958).
* debug.txi: Note that dbstop can be used with class methods as well
(bug #40958).
author | Rik <rik@octave.org> |
---|---|
date | Wed, 01 Jan 2014 18:24:55 -0800 |
parents | c3cd335bd71b |
children | b560bac0fca2 |
rev | line source |
---|---|
2075 | 1 /* |
2 | |
17744
d63878346099
maint: Update copyright notices for release.
John W. Eaton <jwe@octave.org>
parents:
17397
diff
changeset
|
3 Copyright (C) 1996-2013 John W. Eaton |
10521
4d1fc073fbb7
add some missing copyright stmts
Jaroslav Hajek <highegg@gmail.com>
parents:
10336
diff
changeset
|
4 Copyright (C) 2010 VZLU Prague |
2075 | 5 |
6 This file is part of Octave. | |
7 | |
8 Octave is free software; you can redistribute it and/or modify it | |
9 under the terms of the GNU General Public License as published by the | |
7016 | 10 Free Software Foundation; either version 3 of the License, or (at your |
11 option) any later version. | |
2075 | 12 |
13 Octave is distributed in the hope that it will be useful, but WITHOUT | |
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
16 for more details. | |
17 | |
18 You should have received a copy of the GNU General Public License | |
7016 | 19 along with Octave; see the file COPYING. If not, see |
20 <http://www.gnu.org/licenses/>. | |
2075 | 21 |
22 */ | |
23 | |
24 // Thomas Baier <baier@ci.tuwien.ac.at> added the original versions of | |
25 // the following functions: | |
26 // | |
27 // mkfifo unlink waitpid | |
28 | |
29 #ifdef HAVE_CONFIG_H | |
30 #include <config.h> | |
31 #endif | |
32 | |
33 #include <cstdio> | |
2669 | 34 #include <cstring> |
2075 | 35 |
36 #include <sys/types.h> | |
37 #include <unistd.h> | |
38 | |
39 #include <fcntl.h> | |
40 | |
17236
6a6e3f1a824c
save history on exec (bug #39734)
John W. Eaton <jwe@octave.org>
parents:
15221
diff
changeset
|
41 #include "cmd-hist.h" |
2926 | 42 #include "file-ops.h" |
43 #include "file-stat.h" | |
11006
aca961a3f387
provide gethostname function
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
44 #include "oct-env.h" |
2937 | 45 #include "oct-syscalls.h" |
5547 | 46 #include "oct-uname.h" |
2926 | 47 |
2075 | 48 #include "defun.h" |
49 #include "error.h" | |
2078 | 50 #include "gripes.h" |
2075 | 51 #include "lo-utils.h" |
17236
6a6e3f1a824c
save history on exec (bug #39734)
John W. Eaton <jwe@octave.org>
parents:
15221
diff
changeset
|
52 #include "oct-hist.h" |
2075 | 53 #include "oct-map.h" |
54 #include "oct-obj.h" | |
55 #include "oct-stdstrm.h" | |
56 #include "oct-stream.h" | |
57 #include "sysdep.h" | |
58 #include "utils.h" | |
2366 | 59 #include "variables.h" |
6321 | 60 #include "input.h" |
2075 | 61 |
10762
d53eb6249892
use scalar map in some syscalls
Jaroslav Hajek <highegg@gmail.com>
parents:
10521
diff
changeset
|
62 static octave_scalar_map |
8549 | 63 mk_stat_map (const base_file_stat& fs) |
2075 | 64 { |
10762
d53eb6249892
use scalar map in some syscalls
Jaroslav Hajek <highegg@gmail.com>
parents:
10521
diff
changeset
|
65 octave_scalar_map m; |
2075 | 66 |
4675 | 67 m.assign ("dev", static_cast<double> (fs.dev ())); |
68 m.assign ("ino", fs.ino ()); | |
5476 | 69 m.assign ("mode", fs.mode ()); |
4675 | 70 m.assign ("modestr", fs.mode_as_string ()); |
71 m.assign ("nlink", fs.nlink ()); | |
72 m.assign ("uid", fs.uid ()); | |
73 m.assign ("gid", fs.gid ()); | |
3887 | 74 #if defined (HAVE_STRUCT_STAT_ST_RDEV) |
4675 | 75 m.assign ("rdev", static_cast<double> (fs.rdev ())); |
2075 | 76 #endif |
4675 | 77 m.assign ("size", fs.size ()); |
78 m.assign ("atime", fs.atime ()); | |
79 m.assign ("mtime", fs.mtime ()); | |
80 m.assign ("ctime", fs.ctime ()); | |
3887 | 81 #if defined (HAVE_STRUCT_STAT_ST_BLKSIZE) |
4675 | 82 m.assign ("blksize", fs.blksize ()); |
2075 | 83 #endif |
3887 | 84 #if defined (HAVE_STRUCT_STAT_ST_BLOCKS) |
4675 | 85 m.assign ("blocks", fs.blocks ()); |
2075 | 86 #endif |
87 | |
88 return m; | |
89 } | |
90 | |
10336
1603dfe72933
obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
91 static octave_value_list |
1603dfe72933
obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
92 mk_stat_result (const base_file_stat& fs) |
1603dfe72933
obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
93 { |
1603dfe72933
obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
94 octave_value_list retval; |
1603dfe72933
obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
95 |
1603dfe72933
obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
96 if (fs) |
1603dfe72933
obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
97 { |
1603dfe72933
obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
98 retval(2) = std::string (); |
1603dfe72933
obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
99 retval(1) = 0; |
1603dfe72933
obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
100 retval(0) = octave_value (mk_stat_map (fs)); |
1603dfe72933
obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
101 } |
1603dfe72933
obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
102 else |
1603dfe72933
obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
103 { |
1603dfe72933
obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
104 retval(2) = fs.error (); |
1603dfe72933
obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
105 retval(1) = -1; |
1603dfe72933
obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
106 retval(0) = Matrix (); |
1603dfe72933
obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
107 } |
1603dfe72933
obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
108 |
1603dfe72933
obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
109 return retval; |
1603dfe72933
obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
110 } |
1603dfe72933
obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
111 |
10299
c992efc0c2fa
use DEFUNX instead of DEFUN for all functions in syscalls.cc
John W. Eaton <jwe@octave.org>
parents:
10259
diff
changeset
|
112 DEFUNX ("dup2", Fdup2, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
113 "-*- texinfo -*-\n\ |
3301 | 114 @deftypefn {Built-in Function} {[@var{fid}, @var{msg}] =} dup2 (@var{old}, @var{new})\n\ |
2669 | 115 Duplicate a file descriptor.\n\ |
116 \n\ | |
3301 | 117 If successful, @var{fid} is greater than zero and contains the new file\n\ |
10840 | 118 ID@. Otherwise, @var{fid} is negative and @var{msg} contains a\n\ |
3301 | 119 system-dependent error message.\n\ |
120 @end deftypefn") | |
2075 | 121 { |
2669 | 122 octave_value_list retval; |
123 | |
3523 | 124 retval(1) = std::string (); |
4294 | 125 retval(0) = -1; |
2075 | 126 |
127 int nargin = args.length (); | |
128 | |
129 if (nargin == 2) | |
130 { | |
3341 | 131 octave_stream old_stream |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
132 = octave_stream_list::lookup (args(0), "dup2"); |
2075 | 133 |
3341 | 134 if (! error_state) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
135 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
136 octave_stream new_stream |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
137 = octave_stream_list::lookup (args(1), "dup2"); |
2075 | 138 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
139 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
140 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
141 int i_old = old_stream.file_number (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
142 int i_new = new_stream.file_number (); |
2937 | 143 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
144 if (i_old >= 0 && i_new >= 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
145 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
146 std::string msg; |
2669 | 147 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
148 int status = octave_syscalls::dup2 (i_old, i_new, msg); |
3341 | 149 |
14022
de90542b7afc
Return retval(1) before retval(0) to avoid re-sizing call on retval.
Rik <octave@nomad.inbox5.com>
parents:
12642
diff
changeset
|
150 retval(1) = msg; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
151 retval(0) = status; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
152 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
153 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
154 } |
3145 | 155 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
156 error ("dup2: invalid stream"); |
2075 | 157 } |
158 else | |
5823 | 159 print_usage (); |
2075 | 160 |
161 return retval; | |
162 } | |
163 | |
10299
c992efc0c2fa
use DEFUNX instead of DEFUN for all functions in syscalls.cc
John W. Eaton <jwe@octave.org>
parents:
10259
diff
changeset
|
164 DEFUNX ("exec", Fexec, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
165 "-*- texinfo -*-\n\ |
3301 | 166 @deftypefn {Built-in Function} {[@var{err}, @var{msg}] =} exec (@var{file}, @var{args})\n\ |
167 Replace current process with a new process. Calling @code{exec} without\n\ | |
168 first calling @code{fork} will terminate your current Octave process and\n\ | |
169 replace it with the program named by @var{file}. For example,\n\ | |
2669 | 170 \n\ |
3301 | 171 @example\n\ |
172 exec (\"ls\" \"-l\")\n\ | |
173 @end example\n\ | |
2669 | 174 \n\ |
3301 | 175 @noindent\n\ |
176 will run @code{ls} and return you to your shell prompt.\n\ | |
177 \n\ | |
178 If successful, @code{exec} does not return. If @code{exec} does return,\n\ | |
179 @var{err} will be nonzero, and @var{msg} will contain a system-dependent\n\ | |
180 error message.\n\ | |
181 @end deftypefn") | |
2075 | 182 { |
2669 | 183 octave_value_list retval; |
184 | |
3523 | 185 retval(1) = std::string (); |
4294 | 186 retval(0) = -1; |
2075 | 187 |
188 int nargin = args.length (); | |
189 | |
190 if (nargin == 1 || nargin == 2) | |
191 { | |
3523 | 192 std::string exec_file = args(0).string_value (); |
2075 | 193 |
194 if (! error_state) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
195 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
196 string_vector exec_args; |
2075 | 197 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
198 if (nargin == 2) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
199 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
200 string_vector tmp = args(1).all_strings (); |
2075 | 201 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
202 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
203 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
204 int len = tmp.length (); |
2075 | 205 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
206 exec_args.resize (len + 1); |
2075 | 207 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
208 exec_args[0] = exec_file; |
2075 | 209 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
210 for (int i = 0; i < len; i++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
211 exec_args[i+1] = tmp[i]; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
212 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
213 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
214 error ("exec: arguments must be character strings"); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
215 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
216 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
217 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
218 exec_args.resize (1); |
2075 | 219 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
220 exec_args[0] = exec_file; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
221 } |
2075 | 222 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
223 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
224 { |
17236
6a6e3f1a824c
save history on exec (bug #39734)
John W. Eaton <jwe@octave.org>
parents:
15221
diff
changeset
|
225 octave_history_write_timestamp (); |
6a6e3f1a824c
save history on exec (bug #39734)
John W. Eaton <jwe@octave.org>
parents:
15221
diff
changeset
|
226 |
6a6e3f1a824c
save history on exec (bug #39734)
John W. Eaton <jwe@octave.org>
parents:
15221
diff
changeset
|
227 if (! command_history::ignoring_entries ()) |
6a6e3f1a824c
save history on exec (bug #39734)
John W. Eaton <jwe@octave.org>
parents:
15221
diff
changeset
|
228 command_history::clean_up_and_save (); |
6a6e3f1a824c
save history on exec (bug #39734)
John W. Eaton <jwe@octave.org>
parents:
15221
diff
changeset
|
229 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
230 std::string msg; |
2937 | 231 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
232 int status = octave_syscalls::execvp (exec_file, exec_args, msg); |
2669 | 233 |
14022
de90542b7afc
Return retval(1) before retval(0) to avoid re-sizing call on retval.
Rik <octave@nomad.inbox5.com>
parents:
12642
diff
changeset
|
234 retval(1) = msg; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
235 retval(0) = status; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
236 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
237 } |
2075 | 238 else |
12483
7a5aacf65f81
Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents:
12212
diff
changeset
|
239 error ("exec: FILE must be a string"); |
2075 | 240 } |
241 else | |
5823 | 242 print_usage (); |
2075 | 243 |
244 return retval; | |
245 } | |
246 | |
10299
c992efc0c2fa
use DEFUNX instead of DEFUN for all functions in syscalls.cc
John W. Eaton <jwe@octave.org>
parents:
10259
diff
changeset
|
247 DEFUNX ("popen2", Fpopen2, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
248 "-*- texinfo -*-\n\ |
6678 | 249 @deftypefn {Built-in Function} {[@var{in}, @var{out}, @var{pid}] =} popen2 (@var{command}, @var{args})\n\ |
6321 | 250 Start a subprocess with two-way communication. The name of the process\n\ |
251 is given by @var{command}, and @var{args} is an array of strings\n\ | |
252 containing options for the command. The file identifiers for the input\n\ | |
253 and output streams of the subprocess are returned in @var{in} and\n\ | |
254 @var{out}. If execution of the command is successful, @var{pid}\n\ | |
255 contains the process ID of the subprocess. Otherwise, @var{pid} is\n\ | |
256 @minus{}1.\n\ | |
257 \n\ | |
10840 | 258 For example:\n\ |
6321 | 259 \n\ |
260 @example\n\ | |
6923 | 261 [in, out, pid] = popen2 (\"sort\", \"-r\");\n\ |
6321 | 262 fputs (in, \"these\\nare\\nsome\\nstrings\\n\");\n\ |
263 fclose (in);\n\ | |
264 EAGAIN = errno (\"EAGAIN\");\n\ | |
265 done = false;\n\ | |
266 do\n\ | |
267 s = fgets (out);\n\ | |
268 if (ischar (s))\n\ | |
269 fputs (stdout, s);\n\ | |
270 elseif (errno () == EAGAIN)\n\ | |
271 sleep (0.1);\n\ | |
272 fclear (out);\n\ | |
273 else\n\ | |
274 done = true;\n\ | |
275 endif\n\ | |
276 until (done)\n\ | |
277 fclose (out);\n\ | |
9563
f5c28d8f5147
syscalls.cc: Recommend waitpid() in popen2() documentation.
Rob Mahurin <rob@utk.edu>
parents:
9209
diff
changeset
|
278 waitpid (pid);\n\ |
14360
97883071e8e4
doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents:
14171
diff
changeset
|
279 \n\ |
97883071e8e4
doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents:
14171
diff
changeset
|
280 @print{} these\n\ |
97883071e8e4
doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents:
14171
diff
changeset
|
281 @print{} strings\n\ |
97883071e8e4
doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents:
14171
diff
changeset
|
282 @print{} some\n\ |
97883071e8e4
doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents:
14171
diff
changeset
|
283 @print{} are\n\ |
6321 | 284 @end example\n\ |
9563
f5c28d8f5147
syscalls.cc: Recommend waitpid() in popen2() documentation.
Rob Mahurin <rob@utk.edu>
parents:
9209
diff
changeset
|
285 \n\ |
17968
43c199e83ed7
Reap child process in popen2 %!test block.
Rik <rik@octave.org>
parents:
17951
diff
changeset
|
286 Note that @code{popen2}, unlike @code{popen}, will not @nospell{\"reap\"} the\n\ |
9563
f5c28d8f5147
syscalls.cc: Recommend waitpid() in popen2() documentation.
Rob Mahurin <rob@utk.edu>
parents:
9209
diff
changeset
|
287 child process. If you don't use @code{waitpid} to check the child's\n\ |
9564 | 288 exit status, it will linger until Octave exits.\n\ |
17968
43c199e83ed7
Reap child process in popen2 %!test block.
Rik <rik@octave.org>
parents:
17951
diff
changeset
|
289 @seealso{popen, waitpid}\n\ |
6321 | 290 @end deftypefn") |
291 { | |
292 octave_value_list retval; | |
293 | |
294 retval(2) = -1; | |
295 retval(1) = Matrix (); | |
296 retval(0) = Matrix (); | |
297 | |
298 int nargin = args.length (); | |
299 | |
300 if (nargin >= 1 && nargin <= 3) | |
301 { | |
14846
460a3c6d8bf1
maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents:
14819
diff
changeset
|
302 std::string exec_file = args(0).string_value (); |
6321 | 303 |
304 if (! error_state) | |
305 { | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
306 string_vector arg_list; |
6321 | 307 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
308 if (nargin >= 2) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
309 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
310 string_vector tmp = args(1).all_strings (); |
6321 | 311 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
312 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
313 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
314 int len = tmp.length (); |
6321 | 315 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
316 arg_list.resize (len + 1); |
6321 | 317 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
318 arg_list[0] = exec_file; |
6321 | 319 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
320 for (int i = 0; i < len; i++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
321 arg_list[i+1] = tmp[i]; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
322 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
323 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
324 error ("popen2: arguments must be character strings"); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
325 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
326 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
327 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
328 arg_list.resize (1); |
6321 | 329 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
330 arg_list[0] = exec_file; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
331 } |
6321 | 332 |
333 if (! error_state) | |
334 { | |
14846
460a3c6d8bf1
maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents:
14819
diff
changeset
|
335 bool sync_mode = (nargin == 3 ? args(2).bool_value () : false); |
6321 | 336 |
337 if (! error_state) | |
338 { | |
339 int fildes[2]; | |
340 std::string msg; | |
341 pid_t pid; | |
342 | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
343 pid = octave_syscalls::popen2 (exec_file, arg_list, sync_mode, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
344 fildes, msg, interactive); |
6321 | 345 if (pid >= 0) |
346 { | |
347 FILE *ifile = fdopen (fildes[1], "r"); | |
348 FILE *ofile = fdopen (fildes[0], "w"); | |
349 | |
350 std::string nm; | |
351 | |
352 octave_stream is = octave_stdiostream::create (nm, ifile, | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
353 std::ios::in); |
6321 | 354 |
355 octave_stream os = octave_stdiostream::create (nm, ofile, | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
356 std::ios::out); |
6321 | 357 |
358 Cell file_ids (1, 2); | |
359 | |
14022
de90542b7afc
Return retval(1) before retval(0) to avoid re-sizing call on retval.
Rik <octave@nomad.inbox5.com>
parents:
12642
diff
changeset
|
360 retval(2) = pid; |
6321 | 361 retval(1) = octave_stream_list::insert (is); |
14022
de90542b7afc
Return retval(1) before retval(0) to avoid re-sizing call on retval.
Rik <octave@nomad.inbox5.com>
parents:
12642
diff
changeset
|
362 retval(0) = octave_stream_list::insert (os); |
6321 | 363 } |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
364 else |
6321 | 365 error (msg.c_str ()); |
366 } | |
367 } | |
368 else | |
369 error ("popen2: arguments must be character strings"); | |
370 } | |
371 else | |
12483
7a5aacf65f81
Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents:
12212
diff
changeset
|
372 error ("popen2: COMMAND argument must be a string"); |
6321 | 373 } |
374 else | |
375 print_usage (); | |
376 | |
377 return retval; | |
378 } | |
379 | |
380 /* | |
18022
c3cd335bd71b
Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents:
17969
diff
changeset
|
381 |
c3cd335bd71b
Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents:
17969
diff
changeset
|
382 %!test # UNIX-style test |
c3cd335bd71b
Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents:
17969
diff
changeset
|
383 %! if (isunix () || ismac ()) |
c3cd335bd71b
Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents:
17969
diff
changeset
|
384 %! [in, out, pid] = popen2 ("sort", "-r"); |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
385 %! EAGAIN = errno ("EAGAIN"); |
18022
c3cd335bd71b
Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents:
17969
diff
changeset
|
386 %! fputs (in, "these\nare\nsome\nstrings\n"); |
c3cd335bd71b
Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents:
17969
diff
changeset
|
387 %! fclose (in); |
c3cd335bd71b
Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents:
17969
diff
changeset
|
388 %! done = false; |
c3cd335bd71b
Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents:
17969
diff
changeset
|
389 %! str = {}; |
c3cd335bd71b
Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents:
17969
diff
changeset
|
390 %! idx = 0; |
c3cd335bd71b
Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents:
17969
diff
changeset
|
391 %! errs = 0; |
c3cd335bd71b
Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents:
17969
diff
changeset
|
392 %! do |
c3cd335bd71b
Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents:
17969
diff
changeset
|
393 %! if (ismac ()) # FIXME: Is this necessary? |
c3cd335bd71b
Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents:
17969
diff
changeset
|
394 %! errno (0); |
c3cd335bd71b
Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents:
17969
diff
changeset
|
395 %! endif |
c3cd335bd71b
Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents:
17969
diff
changeset
|
396 %! s = fgets (out); |
c3cd335bd71b
Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents:
17969
diff
changeset
|
397 %! if (ischar (s)) |
c3cd335bd71b
Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents:
17969
diff
changeset
|
398 %! idx++; |
c3cd335bd71b
Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents:
17969
diff
changeset
|
399 %! str{idx} = s; |
c3cd335bd71b
Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents:
17969
diff
changeset
|
400 %! elseif (errno () == EAGAIN) |
c3cd335bd71b
Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents:
17969
diff
changeset
|
401 %! fclear (out); |
c3cd335bd71b
Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents:
17969
diff
changeset
|
402 %! sleep (0.1); |
c3cd335bd71b
Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents:
17969
diff
changeset
|
403 %! if (++errs == 100) |
c3cd335bd71b
Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents:
17969
diff
changeset
|
404 %! done = true; |
c3cd335bd71b
Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents:
17969
diff
changeset
|
405 %! endif |
c3cd335bd71b
Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents:
17969
diff
changeset
|
406 %! else |
6321 | 407 %! done = true; |
408 %! endif | |
18022
c3cd335bd71b
Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents:
17969
diff
changeset
|
409 %! until (done) |
c3cd335bd71b
Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents:
17969
diff
changeset
|
410 %! fclose (out); |
c3cd335bd71b
Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents:
17969
diff
changeset
|
411 %! waitpid (pid); |
14861
f7afecdd87ef
maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents:
14846
diff
changeset
|
412 %! assert (str, {"these\n","strings\n","some\n","are\n"}); |
18022
c3cd335bd71b
Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents:
17969
diff
changeset
|
413 %! endif |
c3cd335bd71b
Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents:
17969
diff
changeset
|
414 |
c3cd335bd71b
Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents:
17969
diff
changeset
|
415 %!test # Windows-style test |
c3cd335bd71b
Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents:
17969
diff
changeset
|
416 %! if (ispc () && ! isunix ()) |
c3cd335bd71b
Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents:
17969
diff
changeset
|
417 %! [in, out, pid] = popen2 ('C:\Windows\system32\sort.exe', "/R"); |
c3cd335bd71b
Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents:
17969
diff
changeset
|
418 %! EAGAIN = errno ("EINVAL"); |
c3cd335bd71b
Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents:
17969
diff
changeset
|
419 %! fputs (in, "these\r\nare\r\nsome\r\nstrings\r\n"); |
c3cd335bd71b
Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents:
17969
diff
changeset
|
420 %! fclose (in); |
c3cd335bd71b
Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents:
17969
diff
changeset
|
421 %! done = false; |
c3cd335bd71b
Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents:
17969
diff
changeset
|
422 %! str = {}; |
c3cd335bd71b
Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents:
17969
diff
changeset
|
423 %! idx = 0; |
c3cd335bd71b
Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents:
17969
diff
changeset
|
424 %! errs = 0; |
c3cd335bd71b
Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents:
17969
diff
changeset
|
425 %! do |
c3cd335bd71b
Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents:
17969
diff
changeset
|
426 %! errno (0); |
c3cd335bd71b
Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents:
17969
diff
changeset
|
427 %! s = fgets (out); |
c3cd335bd71b
Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents:
17969
diff
changeset
|
428 %! if (ischar (s)) |
c3cd335bd71b
Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents:
17969
diff
changeset
|
429 %! idx++; |
c3cd335bd71b
Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents:
17969
diff
changeset
|
430 %! str{idx} = s; |
c3cd335bd71b
Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents:
17969
diff
changeset
|
431 %! elseif (errno () == EAGAIN) |
c3cd335bd71b
Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents:
17969
diff
changeset
|
432 %! fclear (out); |
c3cd335bd71b
Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents:
17969
diff
changeset
|
433 %! sleep (0.1); |
c3cd335bd71b
Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents:
17969
diff
changeset
|
434 %! if (++errs == 100) |
c3cd335bd71b
Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents:
17969
diff
changeset
|
435 %! done = true; |
c3cd335bd71b
Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents:
17969
diff
changeset
|
436 %! endif |
c3cd335bd71b
Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents:
17969
diff
changeset
|
437 %! else |
c3cd335bd71b
Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents:
17969
diff
changeset
|
438 %! done = true; |
c3cd335bd71b
Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents:
17969
diff
changeset
|
439 %! endif |
c3cd335bd71b
Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents:
17969
diff
changeset
|
440 %! until (done) |
c3cd335bd71b
Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents:
17969
diff
changeset
|
441 %! fclose (out); |
c3cd335bd71b
Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents:
17969
diff
changeset
|
442 %! waitpid (pid); |
14861
f7afecdd87ef
maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents:
14846
diff
changeset
|
443 %! assert (str, {"these\r\n","strings\r\n","some\r\n","are\r\n"}); |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
444 %! endif |
18022
c3cd335bd71b
Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents:
17969
diff
changeset
|
445 |
6321 | 446 */ |
447 | |
10259 | 448 DEFUNX ("fcntl", Ffcntl, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
449 "-*- texinfo -*-\n\ |
3301 | 450 @deftypefn {Built-in Function} {[@var{err}, @var{msg}] =} fcntl (@var{fid}, @var{request}, @var{arg})\n\ |
451 Change the properties of the open file @var{fid}. The following values\n\ | |
452 may be passed as @var{request}:\n\ | |
453 \n\ | |
454 @vtable @code\n\ | |
455 @item F_DUPFD\n\ | |
456 Return a duplicate file descriptor.\n\ | |
457 \n\ | |
458 @item F_GETFD\n\ | |
459 Return the file descriptor flags for @var{fid}.\n\ | |
460 \n\ | |
461 @item F_SETFD\n\ | |
462 Set the file descriptor flags for @var{fid}.\n\ | |
463 \n\ | |
464 @item F_GETFL\n\ | |
465 Return the file status flags for @var{fid}. The following codes may be\n\ | |
466 returned (some of the flags may be undefined on some systems).\n\ | |
467 \n\ | |
468 @vtable @code\n\ | |
469 @item O_RDONLY\n\ | |
470 Open for reading only.\n\ | |
471 \n\ | |
472 @item O_WRONLY\n\ | |
473 Open for writing only.\n\ | |
2669 | 474 \n\ |
3301 | 475 @item O_RDWR\n\ |
476 Open for reading and writing.\n\ | |
477 \n\ | |
478 @item O_APPEND\n\ | |
479 Append on each write.\n\ | |
480 \n\ | |
5040 | 481 @item O_CREAT\n\ |
482 Create the file if it does not exist.\n\ | |
483 \n\ | |
3301 | 484 @item O_NONBLOCK\n\ |
10791
3140cb7a05a1
Add spellchecker scripts for Octave and run spellcheck of documentation
Rik <octave@nomad.inbox5.com>
parents:
10762
diff
changeset
|
485 Non-blocking mode.\n\ |
3301 | 486 \n\ |
487 @item O_SYNC\n\ | |
488 Wait for writes to complete.\n\ | |
2669 | 489 \n\ |
3301 | 490 @item O_ASYNC\n\ |
491 Asynchronous I/O.\n\ | |
492 @end vtable\n\ | |
493 \n\ | |
494 @item F_SETFL\n\ | |
495 Set the file status flags for @var{fid} to the value specified by\n\ | |
9209
923c7cb7f13f
Simplify TeXinfo files by eliminating redundant @iftex followed by @tex construction.
Rik <rdrider0-list@yahoo.com>
parents:
9064
diff
changeset
|
496 @var{arg}. The only flags that can be changed are @w{@code{O_APPEND}} and\n\ |
923c7cb7f13f
Simplify TeXinfo files by eliminating redundant @iftex followed by @tex construction.
Rik <rdrider0-list@yahoo.com>
parents:
9064
diff
changeset
|
497 @w{@code{O_NONBLOCK}}.\n\ |
3301 | 498 @end vtable\n\ |
499 \n\ | |
500 If successful, @var{err} is 0 and @var{msg} is an empty string.\n\ | |
501 Otherwise, @var{err} is nonzero and @var{msg} contains a\n\ | |
502 system-dependent error message.\n\ | |
503 @end deftypefn") | |
2075 | 504 { |
2669 | 505 octave_value_list retval; |
506 | |
3523 | 507 retval(1) = std::string (); |
4294 | 508 retval(0) = -1; |
2075 | 509 |
510 int nargin = args.length (); | |
511 | |
512 if (nargin == 3) | |
513 { | |
3715 | 514 octave_stream strm = octave_stream_list::lookup (args (0), "fcntl"); |
2075 | 515 |
3202 | 516 if (! error_state) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
517 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
518 int fid = strm.file_number (); |
3715 | 519 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
520 int req = args(1).int_value (true); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
521 int arg = args(2).int_value (true); |
3715 | 522 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
523 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
524 { |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
525 // FIXME: Need better checking here? |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
526 if (fid < 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
527 error ("fcntl: invalid file id"); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
528 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
529 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
530 std::string msg; |
2937 | 531 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
532 int status = octave_fcntl (fid, req, arg, msg); |
2669 | 533 |
14022
de90542b7afc
Return retval(1) before retval(0) to avoid re-sizing call on retval.
Rik <octave@nomad.inbox5.com>
parents:
12642
diff
changeset
|
534 retval(1) = msg; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
535 retval(0) = status; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
536 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
537 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
538 } |
2075 | 539 else |
12483
7a5aacf65f81
Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents:
12212
diff
changeset
|
540 error ("fcntl: FID, REQUEST, and ARG must be integers"); |
2075 | 541 } |
542 else | |
5823 | 543 print_usage (); |
2075 | 544 |
545 return retval; | |
546 } | |
547 | |
10299
c992efc0c2fa
use DEFUNX instead of DEFUN for all functions in syscalls.cc
John W. Eaton <jwe@octave.org>
parents:
10259
diff
changeset
|
548 DEFUNX ("fork", Ffork, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
549 "-*- texinfo -*-\n\ |
3301 | 550 @deftypefn {Built-in Function} {[@var{pid}, @var{msg}] =} fork ()\n\ |
2669 | 551 Create a copy of the current process.\n\ |
552 \n\ | |
3301 | 553 Fork can return one of the following values:\n\ |
554 \n\ | |
555 @table @asis\n\ | |
556 @item > 0\n\ | |
557 You are in the parent process. The value returned from @code{fork} is\n\ | |
558 the process id of the child process. You should probably arrange to\n\ | |
559 wait for any child processes to exit.\n\ | |
560 \n\ | |
561 @item 0\n\ | |
562 You are in the child process. You can call @code{exec} to start another\n\ | |
563 process. If that fails, you should probably call @code{exit}.\n\ | |
564 \n\ | |
565 @item < 0\n\ | |
566 The call to @code{fork} failed for some reason. You must take evasive\n\ | |
567 action. A system dependent error message will be waiting in @var{msg}.\n\ | |
568 @end table\n\ | |
569 @end deftypefn") | |
2075 | 570 { |
2669 | 571 octave_value_list retval; |
572 | |
3523 | 573 retval(1) = std::string (); |
4294 | 574 retval(0) = -1; |
2075 | 575 |
576 int nargin = args.length (); | |
577 | |
578 if (nargin == 0) | |
2475 | 579 { |
3523 | 580 std::string msg; |
2937 | 581 |
582 pid_t pid = octave_syscalls::fork (msg); | |
2669 | 583 |
14022
de90542b7afc
Return retval(1) before retval(0) to avoid re-sizing call on retval.
Rik <octave@nomad.inbox5.com>
parents:
12642
diff
changeset
|
584 retval(1) = msg; |
4233 | 585 retval(0) = pid; |
2475 | 586 } |
2075 | 587 else |
5823 | 588 print_usage (); |
2075 | 589 |
590 return retval; | |
591 } | |
592 | |
10299
c992efc0c2fa
use DEFUNX instead of DEFUN for all functions in syscalls.cc
John W. Eaton <jwe@octave.org>
parents:
10259
diff
changeset
|
593 DEFUNX ("getpgrp", Fgetpgrp, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
594 "-*- texinfo -*-\n\ |
3301 | 595 @deftypefn {Built-in Function} {pgid =} getpgrp ()\n\ |
596 Return the process group id of the current process.\n\ | |
597 @end deftypefn") | |
2075 | 598 { |
2937 | 599 octave_value_list retval; |
600 | |
3523 | 601 retval(1) = std::string (); |
4294 | 602 retval(0) = -1; |
2075 | 603 |
604 int nargin = args.length (); | |
605 | |
606 if (nargin == 0) | |
2475 | 607 { |
3523 | 608 std::string msg; |
2937 | 609 |
14022
de90542b7afc
Return retval(1) before retval(0) to avoid re-sizing call on retval.
Rik <octave@nomad.inbox5.com>
parents:
12642
diff
changeset
|
610 retval(1) = msg; |
4233 | 611 retval(0) = octave_syscalls::getpgrp (msg); |
2475 | 612 } |
2075 | 613 else |
5823 | 614 print_usage (); |
2075 | 615 |
616 return retval; | |
617 } | |
618 | |
10299
c992efc0c2fa
use DEFUNX instead of DEFUN for all functions in syscalls.cc
John W. Eaton <jwe@octave.org>
parents:
10259
diff
changeset
|
619 DEFUNX ("getpid", Fgetpid, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
620 "-*- texinfo -*-\n\ |
3301 | 621 @deftypefn {Built-in Function} {pid =} getpid ()\n\ |
622 Return the process id of the current process.\n\ | |
623 @end deftypefn") | |
2075 | 624 { |
4233 | 625 octave_value retval = -1; |
2075 | 626 |
627 int nargin = args.length (); | |
628 | |
629 if (nargin == 0) | |
2937 | 630 retval = octave_syscalls::getpid (); |
2075 | 631 else |
5823 | 632 print_usage (); |
2075 | 633 |
634 return retval; | |
635 } | |
636 | |
10299
c992efc0c2fa
use DEFUNX instead of DEFUN for all functions in syscalls.cc
John W. Eaton <jwe@octave.org>
parents:
10259
diff
changeset
|
637 DEFUNX ("getppid", Fgetppid, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
638 "-*- texinfo -*-\n\ |
3301 | 639 @deftypefn {Built-in Function} {pid =} getppid ()\n\ |
640 Return the process id of the parent process.\n\ | |
641 @end deftypefn") | |
2075 | 642 { |
4233 | 643 octave_value retval = -1; |
2075 | 644 |
2475 | 645 int nargin = args.length (); |
646 | |
647 if (nargin == 0) | |
2937 | 648 retval = octave_syscalls::getppid (); |
2475 | 649 else |
5823 | 650 print_usage (); |
2475 | 651 |
652 return retval; | |
653 } | |
654 | |
10299
c992efc0c2fa
use DEFUNX instead of DEFUN for all functions in syscalls.cc
John W. Eaton <jwe@octave.org>
parents:
10259
diff
changeset
|
655 DEFUNX ("getegid", Fgetegid, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
656 "-*- texinfo -*-\n\ |
3301 | 657 @deftypefn {Built-in Function} {egid =} getegid ()\n\ |
658 Return the effective group id of the current process.\n\ | |
659 @end deftypefn") | |
2475 | 660 { |
4233 | 661 octave_value retval = -1; |
2475 | 662 |
2075 | 663 int nargin = args.length (); |
664 | |
665 if (nargin == 0) | |
4254 | 666 retval = octave_syscalls::getegid (); |
2075 | 667 else |
5823 | 668 print_usage (); |
2475 | 669 |
670 return retval; | |
671 } | |
672 | |
10299
c992efc0c2fa
use DEFUNX instead of DEFUN for all functions in syscalls.cc
John W. Eaton <jwe@octave.org>
parents:
10259
diff
changeset
|
673 DEFUNX ("getgid", Fgetgid, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
674 "-*- texinfo -*-\n\ |
3301 | 675 @deftypefn {Built-in Function} {gid =} getgid ()\n\ |
676 Return the real group id of the current process.\n\ | |
677 @end deftypefn") | |
2475 | 678 { |
4233 | 679 octave_value retval = -1; |
2475 | 680 |
681 int nargin = args.length (); | |
682 | |
683 if (nargin == 0) | |
4254 | 684 retval = octave_syscalls::getgid (); |
2475 | 685 else |
5823 | 686 print_usage (); |
2075 | 687 |
688 return retval; | |
689 } | |
690 | |
10299
c992efc0c2fa
use DEFUNX instead of DEFUN for all functions in syscalls.cc
John W. Eaton <jwe@octave.org>
parents:
10259
diff
changeset
|
691 DEFUNX ("geteuid", Fgeteuid, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
692 "-*- texinfo -*-\n\ |
3301 | 693 @deftypefn {Built-in Function} {euid =} geteuid ()\n\ |
694 Return the effective user id of the current process.\n\ | |
695 @end deftypefn") | |
2472 | 696 { |
4233 | 697 octave_value retval = -1; |
2472 | 698 |
699 int nargin = args.length (); | |
700 | |
701 if (nargin == 0) | |
4254 | 702 retval = octave_syscalls::geteuid (); |
2472 | 703 else |
5823 | 704 print_usage (); |
2473 | 705 |
706 return retval; | |
2472 | 707 } |
708 | |
10299
c992efc0c2fa
use DEFUNX instead of DEFUN for all functions in syscalls.cc
John W. Eaton <jwe@octave.org>
parents:
10259
diff
changeset
|
709 DEFUNX ("getuid", Fgetuid, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
710 "-*- texinfo -*-\n\ |
3301 | 711 @deftypefn {Built-in Function} {uid =} getuid ()\n\ |
712 Return the real user id of the current process.\n\ | |
713 @end deftypefn") | |
2472 | 714 { |
4233 | 715 octave_value retval = -1; |
2472 | 716 |
717 int nargin = args.length (); | |
718 | |
719 if (nargin == 0) | |
4254 | 720 retval = octave_syscalls::getuid (); |
2472 | 721 else |
5823 | 722 print_usage (); |
2473 | 723 |
724 return retval; | |
2472 | 725 } |
726 | |
10299
c992efc0c2fa
use DEFUNX instead of DEFUN for all functions in syscalls.cc
John W. Eaton <jwe@octave.org>
parents:
10259
diff
changeset
|
727 DEFUNX ("kill", Fkill, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
728 "-*- texinfo -*-\n\ |
4294 | 729 @deftypefn {Built-in Function} {[@var{err}, @var{msg}] =} kill (@var{pid}, @var{sig})\n\ |
730 Send signal @var{sig} to process @var{pid}.\n\ | |
731 \n\ | |
732 If @var{pid} is positive, then signal @var{sig} is sent to @var{pid}.\n\ | |
733 \n\ | |
734 If @var{pid} is 0, then signal @var{sig} is sent to every process\n\ | |
735 in the process group of the current process.\n\ | |
736 \n\ | |
737 If @var{pid} is -1, then signal @var{sig} is sent to every process\n\ | |
738 except process 1.\n\ | |
739 \n\ | |
740 If @var{pid} is less than -1, then signal @var{sig} is sent to every\n\ | |
741 process in the process group @var{-pid}.\n\ | |
742 \n\ | |
4371 | 743 If @var{sig} is 0, then no signal is sent, but error checking is still\n\ |
4294 | 744 performed.\n\ |
745 \n\ | |
7001 | 746 Return 0 if successful, otherwise return -1.\n\ |
4294 | 747 @end deftypefn") |
748 { | |
749 octave_value_list retval; | |
750 | |
751 retval(1) = std::string (); | |
752 retval(0) = -1; | |
753 | |
754 if (args.length () == 2) | |
755 { | |
756 pid_t pid = args(0).int_value (true); | |
757 | |
758 if (! error_state) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
759 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
760 int sig = args(1).int_value (true); |
4294 | 761 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
762 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
763 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
764 std::string msg; |
4294 | 765 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
766 int status = octave_syscalls::kill (pid, sig, msg); |
4294 | 767 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
768 retval(1) = msg; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
769 retval(0) = status; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
770 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
771 } |
4294 | 772 } |
773 else | |
5823 | 774 print_usage (); |
4294 | 775 |
776 return retval; | |
777 } | |
778 | |
10299
c992efc0c2fa
use DEFUNX instead of DEFUN for all functions in syscalls.cc
John W. Eaton <jwe@octave.org>
parents:
10259
diff
changeset
|
779 DEFUNX ("lstat", Flstat, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
780 "-*- texinfo -*-\n\ |
17397
0bf2fc8562c9
doc: Update documentation for file and directory functions.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
781 @deftypefn {Built-in Function} {@var{info} =} lstat (@var{symlink})\n\ |
0bf2fc8562c9
doc: Update documentation for file and directory functions.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
782 @deftypefnx {Built-in Function} {[@var{info}, @var{err}, @var{msg}] =} lstat (@var{symlink})\n\ |
12211
11faa69c4eaa
Add S_ISBLK and family of functions to documentation.
Rik <octave@nomad.inbox5.com>
parents:
11586
diff
changeset
|
783 Return a structure @var{info} containing information about the symbolic link\n\ |
17397
0bf2fc8562c9
doc: Update documentation for file and directory functions.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
784 @var{symlink}.\n\ |
0bf2fc8562c9
doc: Update documentation for file and directory functions.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
785 \n\ |
0bf2fc8562c9
doc: Update documentation for file and directory functions.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
786 The function outputs are described in the documentation for @code{stat}.\n\ |
0bf2fc8562c9
doc: Update documentation for file and directory functions.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
787 @seealso{stat, symlink}\n\ |
3458 | 788 @end deftypefn") |
2075 | 789 { |
2263 | 790 octave_value_list retval; |
2075 | 791 |
792 if (args.length () == 1) | |
793 { | |
5872 | 794 std::string fname = args(0).string_value (); |
2075 | 795 |
796 if (! error_state) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
797 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
798 file_stat fs (fname, false); |
2075 | 799 |
10336
1603dfe72933
obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
800 retval = mk_stat_result (fs); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
801 } |
2075 | 802 } |
803 else | |
5823 | 804 print_usage (); |
2075 | 805 |
806 return retval; | |
807 } | |
808 | |
10197
4d433bd2d4dc
attempt to avoid trouble with gnulib #defines in a consistent way
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
809 DEFUNX ("mkfifo", Fmkfifo, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
810 "-*- texinfo -*-\n\ |
17397
0bf2fc8562c9
doc: Update documentation for file and directory functions.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
811 @deftypefn {Built-in Function} {} mkfifo (@var{name}, @var{mode})\n\ |
0bf2fc8562c9
doc: Update documentation for file and directory functions.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
812 @deftypefnx {Built-in Function} {[@var{err}, @var{msg}] =} mkfifo (@var{name}, @var{mode})\n\ |
0bf2fc8562c9
doc: Update documentation for file and directory functions.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
813 Create a FIFO special file named @var{name} with file mode @var{mode}\n\ |
2075 | 814 \n\ |
3301 | 815 If successful, @var{err} is 0 and @var{msg} is an empty string.\n\ |
816 Otherwise, @var{err} is nonzero and @var{msg} contains a\n\ | |
817 system-dependent error message.\n\ | |
17397
0bf2fc8562c9
doc: Update documentation for file and directory functions.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
818 @seealso{pipe}\n\ |
3301 | 819 @end deftypefn") |
2075 | 820 { |
2669 | 821 octave_value_list retval; |
822 | |
3523 | 823 retval(1) = std::string (); |
4294 | 824 retval(0) = -1; |
2075 | 825 |
826 int nargin = args.length (); | |
827 | |
828 if (nargin == 2) | |
829 { | |
830 if (args(0).is_string ()) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
831 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
832 std::string name = args(0).string_value (); |
2075 | 833 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
834 if (args(1).is_scalar_type ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
835 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
836 long mode = args(1).long_value (); |
2075 | 837 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
838 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
839 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
840 std::string msg; |
4254 | 841 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
842 int status = octave_mkfifo (name, mode, msg); |
2669 | 843 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
844 retval(0) = status; |
2669 | 845 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
846 if (status < 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
847 retval(1) = msg; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
848 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
849 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
850 error ("mkfifo: invalid MODE"); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
851 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
852 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
853 error ("mkfifo: MODE must be an integer"); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
854 } |
2075 | 855 else |
12483
7a5aacf65f81
Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents:
12212
diff
changeset
|
856 error ("mkfifo: FILE must be a string"); |
2075 | 857 } |
858 else | |
5823 | 859 print_usage (); |
2075 | 860 |
861 return retval; | |
862 } | |
863 | |
10299
c992efc0c2fa
use DEFUNX instead of DEFUN for all functions in syscalls.cc
John W. Eaton <jwe@octave.org>
parents:
10259
diff
changeset
|
864 DEFUNX ("pipe", Fpipe, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
865 "-*- texinfo -*-\n\ |
6321 | 866 @deftypefn {Built-in Function} {[@var{read_fd}, @var{write_fd}, @var{err}, @var{msg}] =} pipe ()\n\ |
867 Create a pipe and return the reading and writing ends of the pipe\n\ | |
868 into @var{read_fd} and @var{write_fd} respectively.\n\ | |
2669 | 869 \n\ |
3301 | 870 If successful, @var{err} is 0 and @var{msg} is an empty string.\n\ |
871 Otherwise, @var{err} is nonzero and @var{msg} contains a\n\ | |
872 system-dependent error message.\n\ | |
17397
0bf2fc8562c9
doc: Update documentation for file and directory functions.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
873 @seealso{mkfifo}\n\ |
3301 | 874 @end deftypefn") |
2075 | 875 { |
2669 | 876 octave_value_list retval; |
877 | |
6321 | 878 retval(3) = std::string (); |
879 retval(2) = -1; | |
4294 | 880 retval(1) = -1; |
6321 | 881 retval(0) = -1; |
2075 | 882 |
883 int nargin = args.length (); | |
884 | |
885 if (nargin == 0) | |
886 { | |
887 int fid[2]; | |
888 | |
3523 | 889 std::string msg; |
2937 | 890 |
891 int status = octave_syscalls::pipe (fid, msg); | |
2669 | 892 |
893 if (status < 0) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
894 retval(3) = msg; |
2669 | 895 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
896 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
897 FILE *ifile = fdopen (fid[0], "r"); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
898 FILE *ofile = fdopen (fid[1], "w"); |
2075 | 899 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
900 std::string nm; |
4327 | 901 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
902 octave_stream is = octave_stdiostream::create (nm, ifile, |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
903 std::ios::in); |
4327 | 904 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
905 octave_stream os = octave_stdiostream::create (nm, ofile, |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
906 std::ios::out); |
2075 | 907 |
14022
de90542b7afc
Return retval(1) before retval(0) to avoid re-sizing call on retval.
Rik <octave@nomad.inbox5.com>
parents:
12642
diff
changeset
|
908 retval(2) = status; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
909 retval(1) = octave_stream_list::insert (os); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
910 retval(0) = octave_stream_list::insert (is); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
911 } |
2075 | 912 } |
913 else | |
5823 | 914 print_usage (); |
2075 | 915 |
916 return retval; | |
917 } | |
918 | |
10299
c992efc0c2fa
use DEFUNX instead of DEFUN for all functions in syscalls.cc
John W. Eaton <jwe@octave.org>
parents:
10259
diff
changeset
|
919 DEFUNX ("stat", Fstat, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
920 "-*- texinfo -*-\n\ |
10840 | 921 @deftypefn {Built-in Function} {[@var{info}, @var{err}, @var{msg}] =} stat (@var{file})\n\ |
11417
1a7b41db5432
Add additional calling form using file descriptor (fid) to docstring for stat.
Rik <octave@nomad.inbox5.com>
parents:
11152
diff
changeset
|
922 @deftypefnx {Built-in Function} {[@var{info}, @var{err}, @var{msg}] =} stat (@var{fid})\n\ |
3301 | 923 @deftypefnx {Built-in Function} {[@var{info}, @var{err}, @var{msg}] =} lstat (@var{file})\n\ |
11417
1a7b41db5432
Add additional calling form using file descriptor (fid) to docstring for stat.
Rik <octave@nomad.inbox5.com>
parents:
11152
diff
changeset
|
924 @deftypefnx {Built-in Function} {[@var{info}, @var{err}, @var{msg}] =} lstat (@var{fid})\n\ |
12211
11faa69c4eaa
Add S_ISBLK and family of functions to documentation.
Rik <octave@nomad.inbox5.com>
parents:
11586
diff
changeset
|
925 Return a structure @var{info} containing the following information about\n\ |
11417
1a7b41db5432
Add additional calling form using file descriptor (fid) to docstring for stat.
Rik <octave@nomad.inbox5.com>
parents:
11152
diff
changeset
|
926 @var{file} or file identifier @var{fid}.\n\ |
3301 | 927 \n\ |
928 @table @code\n\ | |
929 @item dev\n\ | |
930 ID of device containing a directory entry for this file.\n\ | |
931 \n\ | |
932 @item ino\n\ | |
933 File number of the file.\n\ | |
934 \n\ | |
5476 | 935 @item mode\n\ |
9209
923c7cb7f13f
Simplify TeXinfo files by eliminating redundant @iftex followed by @tex construction.
Rik <rdrider0-list@yahoo.com>
parents:
9064
diff
changeset
|
936 File mode, as an integer. Use the functions @w{@code{S_ISREG}},\n\ |
17281
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
17236
diff
changeset
|
937 @w{@code{S_ISDIR}}, @w{@code{S_ISCHR}}, @w{@code{S_ISBLK}},\n\ |
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
17236
diff
changeset
|
938 @w{@code{S_ISFIFO}}, @w{@code{S_ISLNK}}, or @w{@code{S_ISSOCK}} to extract\n\ |
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
17236
diff
changeset
|
939 information from this value.\n\ |
5476 | 940 \n\ |
3301 | 941 @item modestr\n\ |
942 File mode, as a string of ten letters or dashes as would be returned by\n\ | |
943 @kbd{ls -l}.\n\ | |
944 \n\ | |
945 @item nlink\n\ | |
946 Number of links.\n\ | |
2075 | 947 \n\ |
3301 | 948 @item uid\n\ |
949 User ID of file's owner.\n\ | |
950 \n\ | |
951 @item gid\n\ | |
952 Group ID of file's group.\n\ | |
953 \n\ | |
954 @item rdev\n\ | |
955 ID of device for block or character special files.\n\ | |
956 \n\ | |
957 @item size\n\ | |
958 Size in bytes.\n\ | |
959 \n\ | |
960 @item atime\n\ | |
961 Time of last access in the same form as time values returned from\n\ | |
962 @code{time}. @xref{Timing Utilities}.\n\ | |
963 \n\ | |
964 @item mtime\n\ | |
965 Time of last modification in the same form as time values returned from\n\ | |
966 @code{time}. @xref{Timing Utilities}.\n\ | |
2075 | 967 \n\ |
3301 | 968 @item ctime\n\ |
969 Time of last file status change in the same form as time values\n\ | |
970 returned from @code{time}. @xref{Timing Utilities}.\n\ | |
971 \n\ | |
972 @item blksize\n\ | |
973 Size of blocks in the file.\n\ | |
974 \n\ | |
975 @item blocks\n\ | |
976 Number of blocks allocated for file.\n\ | |
977 @end table\n\ | |
978 \n\ | |
979 If the call is successful @var{err} is 0 and @var{msg} is an empty\n\ | |
15065
f7215831fe78
doc: be consistent on var name on stat help text
Carnë Draug <carandraug+dev@gmail.com>
parents:
14861
diff
changeset
|
980 string. If the file does not exist, or some other error occurs, @var{info}\n\ |
3301 | 981 is an empty matrix, @var{err} is @minus{}1, and @var{msg} contains the\n\ |
982 corresponding system error message.\n\ | |
983 \n\ | |
984 If @var{file} is a symbolic link, @code{stat} will return information\n\ | |
7001 | 985 about the actual file that is referenced by the link. Use @code{lstat}\n\ |
3301 | 986 if you want information about the symbolic link itself.\n\ |
987 \n\ | |
10840 | 988 For example:\n\ |
2075 | 989 \n\ |
3301 | 990 @example\n\ |
15065
f7215831fe78
doc: be consistent on var name on stat help text
Carnë Draug <carandraug+dev@gmail.com>
parents:
14861
diff
changeset
|
991 [info, err, msg] = stat (\"/vmlinuz\")\n\ |
f7215831fe78
doc: be consistent on var name on stat help text
Carnë Draug <carandraug+dev@gmail.com>
parents:
14861
diff
changeset
|
992 @result{} info =\n\ |
14360
97883071e8e4
doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents:
14171
diff
changeset
|
993 @{\n\ |
97883071e8e4
doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents:
14171
diff
changeset
|
994 atime = 855399756\n\ |
97883071e8e4
doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents:
14171
diff
changeset
|
995 rdev = 0\n\ |
97883071e8e4
doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents:
14171
diff
changeset
|
996 ctime = 847219094\n\ |
97883071e8e4
doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents:
14171
diff
changeset
|
997 uid = 0\n\ |
97883071e8e4
doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents:
14171
diff
changeset
|
998 size = 389218\n\ |
97883071e8e4
doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents:
14171
diff
changeset
|
999 blksize = 4096\n\ |
97883071e8e4
doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents:
14171
diff
changeset
|
1000 mtime = 847219094\n\ |
97883071e8e4
doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents:
14171
diff
changeset
|
1001 gid = 6\n\ |
97883071e8e4
doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents:
14171
diff
changeset
|
1002 nlink = 1\n\ |
97883071e8e4
doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents:
14171
diff
changeset
|
1003 blocks = 768\n\ |
97883071e8e4
doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents:
14171
diff
changeset
|
1004 mode = -rw-r--r--\n\ |
97883071e8e4
doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents:
14171
diff
changeset
|
1005 modestr = -rw-r--r--\n\ |
97883071e8e4
doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents:
14171
diff
changeset
|
1006 ino = 9316\n\ |
97883071e8e4
doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents:
14171
diff
changeset
|
1007 dev = 2049\n\ |
97883071e8e4
doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents:
14171
diff
changeset
|
1008 @}\n\ |
97883071e8e4
doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents:
14171
diff
changeset
|
1009 @result{} err = 0\n\ |
97883071e8e4
doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents:
14171
diff
changeset
|
1010 @result{} msg =\n\ |
3301 | 1011 @end example\n\ |
17397
0bf2fc8562c9
doc: Update documentation for file and directory functions.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
1012 @seealso{lstat, ls, dir}\n\ |
3301 | 1013 @end deftypefn") |
2075 | 1014 { |
2262 | 1015 octave_value_list retval; |
2075 | 1016 |
1017 if (args.length () == 1) | |
1018 { | |
10336
1603dfe72933
obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
1019 if (args(0).is_scalar_type ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
1020 { |
10336
1603dfe72933
obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
1021 int fid = octave_stream_list::get_file_number (args(0)); |
2075 | 1022 |
10336
1603dfe72933
obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
1023 if (! error_state) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
1024 { |
10336
1603dfe72933
obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
1025 file_fstat fs (fid); |
1603dfe72933
obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
1026 |
1603dfe72933
obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
1027 retval = mk_stat_result (fs); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
1028 } |
10336
1603dfe72933
obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
1029 } |
1603dfe72933
obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
1030 else |
1603dfe72933
obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
1031 { |
1603dfe72933
obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
1032 std::string fname = args(0).string_value (); |
1603dfe72933
obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
1033 |
1603dfe72933
obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
1034 if (! error_state) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
1035 { |
10336
1603dfe72933
obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
1036 file_stat fs (fname); |
1603dfe72933
obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
1037 |
1603dfe72933
obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
1038 retval = mk_stat_result (fs); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
1039 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
1040 } |
2075 | 1041 } |
1042 else | |
5823 | 1043 print_usage (); |
2075 | 1044 |
1045 return retval; | |
1046 } | |
1047 | |
5476 | 1048 DEFUNX ("S_ISREG", FS_ISREG, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1049 "-*- texinfo -*-\n\ |
5476 | 1050 @deftypefn {Built-in Function} {} S_ISREG (@var{mode})\n\ |
17397
0bf2fc8562c9
doc: Update documentation for file and directory functions.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
1051 Return true if @var{mode} corresponds to a regular file.\n\ |
0bf2fc8562c9
doc: Update documentation for file and directory functions.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
1052 \n\ |
0bf2fc8562c9
doc: Update documentation for file and directory functions.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
1053 The value of @var{mode} is assumed to be returned from a call to @code{stat}.\n\ |
5476 | 1054 @seealso{stat, lstat}\n\ |
1055 @end deftypefn") | |
1056 { | |
1057 octave_value retval = false; | |
1058 | |
1059 if (args.length () == 1) | |
1060 { | |
1061 double mode = args(0).double_value (); | |
1062 | |
1063 if (! error_state) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
1064 retval = file_stat::is_reg (static_cast<mode_t> (mode)); |
5476 | 1065 else |
12483
7a5aacf65f81
Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents:
12212
diff
changeset
|
1066 error ("S_ISREG: invalid MODE value"); |
5476 | 1067 } |
1068 else | |
5823 | 1069 print_usage (); |
5476 | 1070 |
1071 return retval; | |
1072 } | |
1073 | |
1074 DEFUNX ("S_ISDIR", FS_ISDIR, args, , | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1075 "-*- texinfo -*-\n\ |
5476 | 1076 @deftypefn {Built-in Function} {} S_ISDIR (@var{mode})\n\ |
17397
0bf2fc8562c9
doc: Update documentation for file and directory functions.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
1077 Return true if @var{mode} corresponds to a directory.\n\ |
0bf2fc8562c9
doc: Update documentation for file and directory functions.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
1078 \n\ |
0bf2fc8562c9
doc: Update documentation for file and directory functions.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
1079 The value of @var{mode} is assumed to be returned from a call to @code{stat}.\n\ |
5476 | 1080 @seealso{stat, lstat}\n\ |
1081 @end deftypefn") | |
1082 { | |
1083 octave_value retval = false; | |
1084 | |
1085 if (args.length () == 1) | |
1086 { | |
1087 double mode = args(0).double_value (); | |
1088 | |
1089 if (! error_state) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
1090 retval = file_stat::is_dir (static_cast<mode_t> (mode)); |
5476 | 1091 else |
12483
7a5aacf65f81
Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents:
12212
diff
changeset
|
1092 error ("S_ISDIR: invalid MODE value"); |
5476 | 1093 } |
1094 else | |
5823 | 1095 print_usage (); |
5476 | 1096 |
1097 return retval; | |
1098 } | |
1099 | |
1100 DEFUNX ("S_ISCHR", FS_ISCHR, args, , | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1101 "-*- texinfo -*-\n\ |
5476 | 1102 @deftypefn {Built-in Function} {} S_ISCHR (@var{mode})\n\ |
17397
0bf2fc8562c9
doc: Update documentation for file and directory functions.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
1103 Return true if @var{mode} corresponds to a character device.\n\ |
0bf2fc8562c9
doc: Update documentation for file and directory functions.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
1104 \n\ |
0bf2fc8562c9
doc: Update documentation for file and directory functions.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
1105 The value of @var{mode} is assumed to be returned from a call to @code{stat}.\n\ |
5476 | 1106 @seealso{stat, lstat}\n\ |
1107 @end deftypefn") | |
1108 { | |
1109 octave_value retval = false; | |
1110 | |
1111 if (args.length () == 1) | |
1112 { | |
1113 double mode = args(0).double_value (); | |
1114 | |
1115 if (! error_state) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
1116 retval = file_stat::is_chr (static_cast<mode_t> (mode)); |
5476 | 1117 else |
12483
7a5aacf65f81
Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents:
12212
diff
changeset
|
1118 error ("S_ISCHR: invalid MODE value"); |
5476 | 1119 } |
1120 else | |
5823 | 1121 print_usage (); |
5476 | 1122 |
1123 return retval; | |
1124 } | |
1125 | |
1126 DEFUNX ("S_ISBLK", FS_ISBLK, args, , | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1127 "-*- texinfo -*-\n\ |
5476 | 1128 @deftypefn {Built-in Function} {} S_ISBLK (@var{mode})\n\ |
17397
0bf2fc8562c9
doc: Update documentation for file and directory functions.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
1129 Return true if @var{mode} corresponds to a block device.\n\ |
0bf2fc8562c9
doc: Update documentation for file and directory functions.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
1130 \n\ |
0bf2fc8562c9
doc: Update documentation for file and directory functions.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
1131 The value of @var{mode} is assumed to be returned from a call to @code{stat}.\n\ |
5476 | 1132 @seealso{stat, lstat}\n\ |
1133 @end deftypefn") | |
1134 { | |
1135 octave_value retval = false; | |
1136 | |
1137 if (args.length () == 1) | |
1138 { | |
1139 double mode = args(0).double_value (); | |
1140 | |
1141 if (! error_state) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
1142 retval = file_stat::is_blk (static_cast<mode_t> (mode)); |
5476 | 1143 else |
12483
7a5aacf65f81
Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents:
12212
diff
changeset
|
1144 error ("S_ISBLK: invalid MODE value"); |
5476 | 1145 } |
1146 else | |
5823 | 1147 print_usage (); |
5476 | 1148 |
1149 return retval; | |
1150 } | |
1151 | |
1152 DEFUNX ("S_ISFIFO", FS_ISFIFO, args, , | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1153 "-*- texinfo -*-\n\ |
5476 | 1154 @deftypefn {Built-in Function} {} S_ISFIFO (@var{mode})\n\ |
17397
0bf2fc8562c9
doc: Update documentation for file and directory functions.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
1155 Return true if @var{mode} corresponds to a fifo.\n\ |
0bf2fc8562c9
doc: Update documentation for file and directory functions.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
1156 \n\ |
0bf2fc8562c9
doc: Update documentation for file and directory functions.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
1157 The value of @var{mode} is assumed to be returned from a call to @code{stat}.\n\ |
5476 | 1158 @seealso{stat, lstat}\n\ |
1159 @end deftypefn") | |
1160 { | |
1161 octave_value retval = false; | |
1162 | |
1163 if (args.length () == 1) | |
1164 { | |
1165 double mode = args(0).double_value (); | |
1166 | |
1167 if (! error_state) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
1168 retval = file_stat::is_fifo (static_cast<mode_t> (mode)); |
5476 | 1169 else |
12483
7a5aacf65f81
Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents:
12212
diff
changeset
|
1170 error ("S_ISFIFO: invalid MODE value"); |
5476 | 1171 } |
1172 else | |
5823 | 1173 print_usage (); |
5476 | 1174 |
1175 return retval; | |
1176 } | |
1177 | |
1178 DEFUNX ("S_ISLNK", FS_ISLNK, args, , | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1179 "-*- texinfo -*-\n\ |
5476 | 1180 @deftypefn {Built-in Function} {} S_ISLNK (@var{mode})\n\ |
17397
0bf2fc8562c9
doc: Update documentation for file and directory functions.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
1181 Return true if @var{mode} corresponds to a symbolic link.\n\ |
0bf2fc8562c9
doc: Update documentation for file and directory functions.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
1182 \n\ |
0bf2fc8562c9
doc: Update documentation for file and directory functions.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
1183 The value of @var{mode} is assumed to be returned from a call to @code{stat}.\n\ |
5476 | 1184 @seealso{stat, lstat}\n\ |
1185 @end deftypefn") | |
1186 { | |
1187 octave_value retval = false; | |
1188 | |
1189 if (args.length () == 1) | |
1190 { | |
1191 double mode = args(0).double_value (); | |
1192 | |
1193 if (! error_state) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
1194 retval = file_stat::is_lnk (static_cast<mode_t> (mode)); |
5476 | 1195 else |
12483
7a5aacf65f81
Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents:
12212
diff
changeset
|
1196 error ("S_ISLNK: invalid MODE value"); |
5476 | 1197 } |
1198 else | |
5823 | 1199 print_usage (); |
5476 | 1200 |
1201 return retval; | |
1202 } | |
1203 | |
1204 DEFUNX ("S_ISSOCK", FS_ISSOCK, args, , | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1205 "-*- texinfo -*-\n\ |
5476 | 1206 @deftypefn {Built-in Function} {} S_ISSOCK (@var{mode})\n\ |
17397
0bf2fc8562c9
doc: Update documentation for file and directory functions.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
1207 Return true if @var{mode} corresponds to a socket.\n\ |
0bf2fc8562c9
doc: Update documentation for file and directory functions.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
1208 \n\ |
0bf2fc8562c9
doc: Update documentation for file and directory functions.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
1209 The value of @var{mode} is assumed to be returned from a call to @code{stat}.\n\ |
5476 | 1210 @seealso{stat, lstat}\n\ |
1211 @end deftypefn") | |
1212 { | |
1213 octave_value retval = false; | |
1214 | |
1215 if (args.length () == 1) | |
1216 { | |
1217 double mode = args(0).double_value (); | |
1218 | |
1219 if (! error_state) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
1220 retval = file_stat::is_sock (static_cast<mode_t> (mode)); |
5476 | 1221 else |
12483
7a5aacf65f81
Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents:
12212
diff
changeset
|
1222 error ("S_ISSOCK: invalid MODE value"); |
5476 | 1223 } |
1224 else | |
5823 | 1225 print_usage (); |
5476 | 1226 |
1227 return retval; | |
1228 } | |
1229 | |
11006
aca961a3f387
provide gethostname function
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
1230 DEFUN (gethostname, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1231 "-*- texinfo -*-\n\ |
12514
e5e66c389597
Add gethostname to documentation.
Rik <octave@nomad.inbox5.com>
parents:
12483
diff
changeset
|
1232 @deftypefn {Built-in Function} {} gethostname ()\n\ |
e5e66c389597
Add gethostname to documentation.
Rik <octave@nomad.inbox5.com>
parents:
12483
diff
changeset
|
1233 Return the hostname of the system where Octave is running.\n\ |
11006
aca961a3f387
provide gethostname function
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
1234 @end deftypefn") |
aca961a3f387
provide gethostname function
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
1235 { |
aca961a3f387
provide gethostname function
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
1236 octave_value retval; |
aca961a3f387
provide gethostname function
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
1237 |
aca961a3f387
provide gethostname function
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
1238 if (args.length () == 0) |
aca961a3f387
provide gethostname function
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
1239 retval = octave_env::get_host_name (); |
aca961a3f387
provide gethostname function
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
1240 else |
aca961a3f387
provide gethostname function
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
1241 print_usage (); |
aca961a3f387
provide gethostname function
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
1242 |
aca961a3f387
provide gethostname function
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
1243 return retval; |
aca961a3f387
provide gethostname function
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
1244 } |
aca961a3f387
provide gethostname function
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
1245 |
5547 | 1246 DEFUN (uname, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1247 "-*- texinfo -*-\n\ |
5547 | 1248 @deftypefn {Built-in Function} {[@var{uts}, @var{err}, @var{msg}] =} uname ()\n\ |
10840 | 1249 Return system information in the structure. For example:\n\ |
5547 | 1250 \n\ |
1251 @example\n\ | |
1252 @group\n\ | |
1253 uname ()\n\ | |
14360
97883071e8e4
doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents:
14171
diff
changeset
|
1254 @result{} @{\n\ |
97883071e8e4
doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents:
14171
diff
changeset
|
1255 sysname = x86_64\n\ |
97883071e8e4
doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents:
14171
diff
changeset
|
1256 nodename = segfault\n\ |
97883071e8e4
doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents:
14171
diff
changeset
|
1257 release = 2.6.15-1-amd64-k8-smp\n\ |
97883071e8e4
doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents:
14171
diff
changeset
|
1258 version = Linux\n\ |
97883071e8e4
doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents:
14171
diff
changeset
|
1259 machine = #2 SMP Thu Feb 23 04:57:49 UTC 2006\n\ |
97883071e8e4
doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents:
14171
diff
changeset
|
1260 @}\n\ |
5547 | 1261 @end group\n\ |
1262 @end example\n\ | |
1263 \n\ | |
1264 If successful, @var{err} is 0 and @var{msg} is an empty string.\n\ | |
1265 Otherwise, @var{err} is nonzero and @var{msg} contains a\n\ | |
1266 system-dependent error message.\n\ | |
1267 @end deftypefn") | |
1268 { | |
1269 octave_value_list retval; | |
1270 | |
1271 if (args.length () == 0) | |
1272 { | |
1273 octave_uname sysinfo; | |
1274 | |
10762
d53eb6249892
use scalar map in some syscalls
Jaroslav Hajek <highegg@gmail.com>
parents:
10521
diff
changeset
|
1275 octave_scalar_map m; |
5547 | 1276 |
1277 m.assign ("sysname", sysinfo.sysname ()); | |
1278 m.assign ("nodename", sysinfo.nodename ()); | |
1279 m.assign ("release", sysinfo.release ()); | |
1280 m.assign ("version", sysinfo.version ()); | |
1281 m.assign ("machine", sysinfo.machine ()); | |
1282 | |
1283 retval(2) = sysinfo.message (); | |
1284 retval(1) = sysinfo.error (); | |
1285 retval(0) = m; | |
1286 } | |
1287 else | |
5823 | 1288 print_usage (); |
5547 | 1289 |
1290 return retval; | |
1291 } | |
1292 | |
10197
4d433bd2d4dc
attempt to avoid trouble with gnulib #defines in a consistent way
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
1293 DEFUNX ("unlink", Funlink, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1294 "-*- texinfo -*-\n\ |
3301 | 1295 @deftypefn {Built-in Function} {[@var{err}, @var{msg}] =} unlink (@var{file})\n\ |
1296 Delete the file named @var{file}.\n\ | |
2075 | 1297 \n\ |
3301 | 1298 If successful, @var{err} is 0 and @var{msg} is an empty string.\n\ |
1299 Otherwise, @var{err} is nonzero and @var{msg} contains a\n\ | |
1300 system-dependent error message.\n\ | |
1301 @end deftypefn") | |
2075 | 1302 { |
2669 | 1303 octave_value_list retval; |
1304 | |
3523 | 1305 retval(1) = std::string (); |
4294 | 1306 retval(0) = -1; |
2075 | 1307 |
1308 int nargin = args.length (); | |
1309 | |
1310 if (nargin == 1) | |
1311 { | |
1312 if (args(0).is_string ()) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
1313 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
1314 std::string name = args(0).string_value (); |
2075 | 1315 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
1316 std::string msg; |
2669 | 1317 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
1318 int status = octave_unlink (name, msg); |
2669 | 1319 |
14022
de90542b7afc
Return retval(1) before retval(0) to avoid re-sizing call on retval.
Rik <octave@nomad.inbox5.com>
parents:
12642
diff
changeset
|
1320 retval(1) = msg; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
1321 retval(0) = status; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
1322 } |
2075 | 1323 else |
12483
7a5aacf65f81
Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents:
12212
diff
changeset
|
1324 error ("unlink: FILE must be a string"); |
2075 | 1325 } |
1326 else | |
5823 | 1327 print_usage (); |
2075 | 1328 |
1329 return retval; | |
1330 } | |
1331 | |
10299
c992efc0c2fa
use DEFUNX instead of DEFUN for all functions in syscalls.cc
John W. Eaton <jwe@octave.org>
parents:
10259
diff
changeset
|
1332 DEFUNX ("waitpid", Fwaitpid, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1333 "-*- texinfo -*-\n\ |
5453 | 1334 @deftypefn {Built-in Function} {[@var{pid}, @var{status}, @var{msg}] =} waitpid (@var{pid}, @var{options})\n\ |
3301 | 1335 Wait for process @var{pid} to terminate. The @var{pid} argument can be:\n\ |
2075 | 1336 \n\ |
3301 | 1337 @table @asis\n\ |
1338 @item @minus{}1\n\ | |
1339 Wait for any child process.\n\ | |
2075 | 1340 \n\ |
3301 | 1341 @item 0\n\ |
1342 Wait for any child process whose process group ID is equal to that of\n\ | |
1343 the Octave interpreter process.\n\ | |
2075 | 1344 \n\ |
3301 | 1345 @item > 0\n\ |
1346 Wait for termination of the child process with ID @var{pid}.\n\ | |
1347 @end table\n\ | |
1348 \n\ | |
5453 | 1349 The @var{options} argument can be a bitwise OR of zero or more of\n\ |
1350 the following constants:\n\ | |
2075 | 1351 \n\ |
5453 | 1352 @table @code\n\ |
3301 | 1353 @item 0\n\ |
1354 Wait until signal is received or a child process exits (this is the\n\ | |
1355 default if the @var{options} argument is missing).\n\ | |
1356 \n\ | |
5453 | 1357 @item WNOHANG\n\ |
3301 | 1358 Do not hang if status is not immediately available.\n\ |
2075 | 1359 \n\ |
5453 | 1360 @item WUNTRACED\n\ |
3301 | 1361 Report the status of any child processes that are stopped, and whose\n\ |
1362 status has not yet been reported since they stopped.\n\ | |
1363 \n\ | |
8286
6f2d95255911
fix @seealso references to point to existing anchors
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7924
diff
changeset
|
1364 @item WCONTINUE\n\ |
5453 | 1365 Return if a stopped child has been resumed by delivery of @code{SIGCONT}.\n\ |
1366 This value may not be meaningful on all systems.\n\ | |
3301 | 1367 @end table\n\ |
1368 \n\ | |
1369 If the returned value of @var{pid} is greater than 0, it is the process\n\ | |
1370 ID of the child process that exited. If an error occurs, @var{pid} will\n\ | |
1371 be less than zero and @var{msg} will contain a system-dependent error\n\ | |
7001 | 1372 message. The value of @var{status} contains additional system-dependent\n\ |
5453 | 1373 information about the subprocess that exited.\n\ |
8286
6f2d95255911
fix @seealso references to point to existing anchors
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7924
diff
changeset
|
1374 @seealso{WCONTINUE, WCOREDUMP, WEXITSTATUS, WIFCONTINUED, WIFSIGNALED, WIFSTOPPED, WNOHANG, WSTOPSIG, WTERMSIG, WUNTRACED}\n\ |
3301 | 1375 @end deftypefn") |
2075 | 1376 { |
2669 | 1377 octave_value_list retval; |
1378 | |
5453 | 1379 retval(2) = std::string (); |
1380 retval(1) = 0; | |
4294 | 1381 retval(0) = -1; |
2075 | 1382 |
1383 int nargin = args.length (); | |
1384 | |
1385 if (nargin == 1 || nargin == 2) | |
1386 { | |
3202 | 1387 pid_t pid = args(0).int_value (true); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
1388 |
2075 | 1389 if (! error_state) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
1390 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
1391 int options = 0; |
2075 | 1392 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
1393 if (args.length () == 2) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
1394 options = args(1).int_value (true); |
2937 | 1395 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
1396 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
1397 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
1398 std::string msg; |
2669 | 1399 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
1400 int status = 0; |
5453 | 1401 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1402 pid_t result = octave_syscalls::waitpid (pid, &status, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1403 options, msg); |
3202 | 1404 |
14022
de90542b7afc
Return retval(1) before retval(0) to avoid re-sizing call on retval.
Rik <octave@nomad.inbox5.com>
parents:
12642
diff
changeset
|
1405 retval(2) = msg; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
1406 retval(1) = status; |
14022
de90542b7afc
Return retval(1) before retval(0) to avoid re-sizing call on retval.
Rik <octave@nomad.inbox5.com>
parents:
12642
diff
changeset
|
1407 retval(0) = result; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
1408 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
1409 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
1410 error ("waitpid: OPTIONS must be an integer"); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
1411 } |
3202 | 1412 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
1413 error ("waitpid: PID must be an integer value"); |
2075 | 1414 } |
1415 else | |
5823 | 1416 print_usage (); |
2075 | 1417 |
1418 return retval; | |
1419 } | |
1420 | |
5453 | 1421 DEFUNX ("WIFEXITED", FWIFEXITED, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1422 "-*- texinfo -*-\n\ |
5453 | 1423 @deftypefn {Built-in Function} {} WIFEXITED (@var{status})\n\ |
1424 Given @var{status} from a call to @code{waitpid}, return true if the\n\ | |
1425 child terminated normally.\n\ | |
1426 @seealso{waitpid, WEXITSTATUS, WIFSIGNALED, WTERMSIG, WCOREDUMP, WIFSTOPPED, WSTOPSIG, WIFCONTINUED}\n\ | |
5646 | 1427 @end deftypefn") |
5453 | 1428 { |
15221
a83b7b2f95ee
avoid C-style cast warnings from GCC for wait-related macros
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
1429 octave_value retval = false; |
5453 | 1430 |
1431 if (args.length () == 1) | |
1432 { | |
1433 int status = args(0).int_value (); | |
1434 | |
1435 if (! error_state) | |
15221
a83b7b2f95ee
avoid C-style cast warnings from GCC for wait-related macros
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
1436 retval = octave_wait::ifexited (status); |
5453 | 1437 else |
12483
7a5aacf65f81
Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents:
12212
diff
changeset
|
1438 error ("WIFEXITED: STATUS must be an integer"); |
5453 | 1439 } |
1440 | |
1441 return retval; | |
1442 } | |
1443 | |
1444 DEFUNX ("WEXITSTATUS", FWEXITSTATUS, args, , | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1445 "-*- texinfo -*-\n\ |
5453 | 1446 @deftypefn {Built-in Function} {} WEXITSTATUS (@var{status})\n\ |
1447 Given @var{status} from a call to @code{waitpid}, return the exit\n\ | |
1448 status of the child. This function should only be employed if\n\ | |
1449 @code{WIFEXITED} returned true.\n\ | |
1450 @seealso{waitpid, WIFEXITED, WIFSIGNALED, WTERMSIG, WCOREDUMP, WIFSTOPPED, WSTOPSIG, WIFCONTINUED}\n\ | |
1451 @end deftypefn") | |
1452 { | |
15221
a83b7b2f95ee
avoid C-style cast warnings from GCC for wait-related macros
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
1453 octave_value retval = 0; |
5453 | 1454 |
1455 if (args.length () == 1) | |
1456 { | |
1457 int status = args(0).int_value (); | |
1458 | |
1459 if (! error_state) | |
15221
a83b7b2f95ee
avoid C-style cast warnings from GCC for wait-related macros
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
1460 retval = octave_wait::exitstatus (status); |
5453 | 1461 else |
12483
7a5aacf65f81
Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents:
12212
diff
changeset
|
1462 error ("WEXITSTATUS: STATUS must be an integer"); |
5453 | 1463 } |
1464 | |
1465 return retval; | |
1466 } | |
1467 | |
1468 DEFUNX ("WIFSIGNALED", FWIFSIGNALED, args, , | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1469 "-*- texinfo -*-\n\ |
5453 | 1470 @deftypefn {Built-in Function} {} WIFSIGNALED (@var{status})\n\ |
1471 Given @var{status} from a call to @code{waitpid}, return true if the\n\ | |
1472 child process was terminated by a signal.\n\ | |
1473 @seealso{waitpid, WIFEXITED, WEXITSTATUS, WTERMSIG, WCOREDUMP, WIFSTOPPED, WSTOPSIG, WIFCONTINUED}\n\ | |
1474 @end deftypefn") | |
1475 { | |
15221
a83b7b2f95ee
avoid C-style cast warnings from GCC for wait-related macros
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
1476 octave_value retval = false; |
5453 | 1477 |
1478 if (args.length () == 1) | |
1479 { | |
1480 int status = args(0).int_value (); | |
1481 | |
1482 if (! error_state) | |
15221
a83b7b2f95ee
avoid C-style cast warnings from GCC for wait-related macros
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
1483 retval = octave_wait::ifsignaled (status); |
5453 | 1484 else |
12483
7a5aacf65f81
Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents:
12212
diff
changeset
|
1485 error ("WIFSIGNALED: STATUS must be an integer"); |
5453 | 1486 } |
1487 | |
1488 return retval; | |
1489 } | |
1490 | |
1491 DEFUNX ("WTERMSIG", FWTERMSIG, args, , | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1492 "-*- texinfo -*-\n\ |
5453 | 1493 @deftypefn {Built-in Function} {} WTERMSIG (@var{status})\n\ |
1494 Given @var{status} from a call to @code{waitpid}, return the number of\n\ | |
9064
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
1495 the signal that caused the child process to terminate. This function\n\ |
5453 | 1496 should only be employed if @code{WIFSIGNALED} returned true.\n\ |
1497 @seealso{waitpid, WIFEXITED, WEXITSTATUS, WIFSIGNALED, WCOREDUMP, WIFSTOPPED, WSTOPSIG, WIFCONTINUED}\n\ | |
1498 @end deftypefn") | |
1499 { | |
15221
a83b7b2f95ee
avoid C-style cast warnings from GCC for wait-related macros
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
1500 octave_value retval = 0; |
5453 | 1501 |
1502 if (args.length () == 1) | |
1503 { | |
1504 int status = args(0).int_value (); | |
1505 | |
1506 if (! error_state) | |
15221
a83b7b2f95ee
avoid C-style cast warnings from GCC for wait-related macros
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
1507 retval = octave_wait::termsig (status); |
5453 | 1508 else |
12483
7a5aacf65f81
Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents:
12212
diff
changeset
|
1509 error ("WTERMSIG: STATUS must be an integer"); |
5453 | 1510 } |
1511 | |
1512 return retval; | |
1513 } | |
1514 | |
1515 DEFUNX ("WCOREDUMP", FWCOREDUMP, args, , | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1516 "-*- texinfo -*-\n\ |
5453 | 1517 @deftypefn {Built-in Function} {} WCOREDUMP (@var{status})\n\ |
1518 Given @var{status} from a call to @code{waitpid}, return true if the\n\ | |
1519 child produced a core dump. This function should only be employed if\n\ | |
1520 @code{WIFSIGNALED} returned true. The macro used to implement this\n\ | |
1521 function is not specified in POSIX.1-2001 and is not available on some\n\ | |
1522 Unix implementations (e.g., AIX, SunOS).\n\ | |
1523 @seealso{waitpid, WIFEXITED, WEXITSTATUS, WIFSIGNALED, WTERMSIG, WIFSTOPPED, WSTOPSIG, WIFCONTINUED}\n\ | |
1524 @end deftypefn") | |
1525 { | |
15221
a83b7b2f95ee
avoid C-style cast warnings from GCC for wait-related macros
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
1526 octave_value retval = false; |
5453 | 1527 |
1528 if (args.length () == 1) | |
1529 { | |
1530 int status = args(0).int_value (); | |
1531 | |
1532 if (! error_state) | |
15221
a83b7b2f95ee
avoid C-style cast warnings from GCC for wait-related macros
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
1533 retval = octave_wait::coredump (status); |
5453 | 1534 else |
12483
7a5aacf65f81
Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents:
12212
diff
changeset
|
1535 error ("WCOREDUMP: STATUS must be an integer"); |
5453 | 1536 } |
1537 | |
1538 return retval; | |
1539 } | |
1540 | |
1541 DEFUNX ("WIFSTOPPED", FWIFSTOPPED, args, , | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1542 "-*- texinfo -*-\n\ |
5453 | 1543 @deftypefn {Built-in Function} {} WIFSTOPPED (@var{status})\n\ |
1544 Given @var{status} from a call to @code{waitpid}, return true if the\n\ | |
1545 child process was stopped by delivery of a signal; this is only\n\ | |
1546 possible if the call was done using @code{WUNTRACED} or when the child\n\ | |
1547 is being traced (see ptrace(2)).\n\ | |
1548 @seealso{waitpid, WIFEXITED, WEXITSTATUS, WIFSIGNALED, WTERMSIG, WCOREDUMP, WSTOPSIG, WIFCONTINUED}\n\ | |
1549 @end deftypefn") | |
1550 { | |
15221
a83b7b2f95ee
avoid C-style cast warnings from GCC for wait-related macros
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
1551 octave_value retval = false; |
5453 | 1552 |
1553 if (args.length () == 1) | |
1554 { | |
1555 int status = args(0).int_value (); | |
1556 | |
1557 if (! error_state) | |
15221
a83b7b2f95ee
avoid C-style cast warnings from GCC for wait-related macros
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
1558 retval = octave_wait::ifstopped (status); |
5453 | 1559 else |
12483
7a5aacf65f81
Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents:
12212
diff
changeset
|
1560 error ("WIFSTOPPED: STATUS must be an integer"); |
5453 | 1561 } |
1562 | |
1563 return retval; | |
1564 } | |
1565 | |
1566 DEFUNX ("WSTOPSIG", FWSTOPSIG, args, , | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1567 "-*- texinfo -*-\n\ |
5453 | 1568 @deftypefn {Built-in Function} {} WSTOPSIG (@var{status})\n\ |
1569 Given @var{status} from a call to @code{waitpid}, return the number of\n\ | |
1570 the signal which caused the child to stop. This function should only\n\ | |
1571 be employed if @code{WIFSTOPPED} returned true.\n\ | |
1572 @seealso{waitpid, WIFEXITED, WEXITSTATUS, WIFSIGNALED, WTERMSIG, WCOREDUMP, WIFSTOPPED, WIFCONTINUED}\n\ | |
1573 @end deftypefn") | |
1574 { | |
15221
a83b7b2f95ee
avoid C-style cast warnings from GCC for wait-related macros
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
1575 octave_value retval = 0; |
5453 | 1576 |
1577 if (args.length () == 1) | |
1578 { | |
1579 int status = args(0).int_value (); | |
1580 | |
1581 if (! error_state) | |
15221
a83b7b2f95ee
avoid C-style cast warnings from GCC for wait-related macros
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
1582 retval = octave_wait::stopsig (status); |
5453 | 1583 else |
12483
7a5aacf65f81
Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents:
12212
diff
changeset
|
1584 error ("WSTOPSIG: STATUS must be an integer"); |
5453 | 1585 } |
1586 | |
1587 return retval; | |
1588 } | |
1589 | |
1590 DEFUNX ("WIFCONTINUED", FWIFCONTINUED, args, , | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1591 "-*- texinfo -*-\n\ |
5453 | 1592 @deftypefn {Built-in Function} {} WIFCONTINUED (@var{status})\n\ |
1593 Given @var{status} from a call to @code{waitpid}, return true if the\n\ | |
1594 child process was resumed by delivery of @code{SIGCONT}.\n\ | |
1595 @seealso{waitpid, WIFEXITED, WEXITSTATUS, WIFSIGNALED, WTERMSIG, WCOREDUMP, WIFSTOPPED, WSTOPSIG}\n\ | |
1596 @end deftypefn") | |
1597 { | |
15221
a83b7b2f95ee
avoid C-style cast warnings from GCC for wait-related macros
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
1598 octave_value retval = false; |
5453 | 1599 |
1600 if (args.length () == 1) | |
1601 { | |
1602 int status = args(0).int_value (); | |
1603 | |
1604 if (! error_state) | |
15221
a83b7b2f95ee
avoid C-style cast warnings from GCC for wait-related macros
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
1605 retval = octave_wait::ifcontinued (status); |
5453 | 1606 else |
12483
7a5aacf65f81
Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents:
12212
diff
changeset
|
1607 error ("WIFCONTINUED: STATUS must be an integer"); |
5453 | 1608 } |
1609 | |
1610 return retval; | |
1611 } | |
1612 | |
10249
14eba566f9f0
use DEFUNX instead of DEFUN for canonicalize_file_name
John W. Eaton <jwe@octave.org>
parents:
10197
diff
changeset
|
1613 DEFUNX ("canonicalize_file_name", Fcanonicalize_file_name, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1614 "-*- texinfo -*-\n\ |
14819
67b6b47a22f6
doc: Clarify docstrings for canonicalize_file_name, make_absolute_filename
Rik <octave@nomad.inbox5.com>
parents:
14429
diff
changeset
|
1615 @deftypefn {Built-in Function} {[@var{cname}, @var{status}, @var{msg}] =} canonicalize_file_name (@var{fname})\n\ |
67b6b47a22f6
doc: Clarify docstrings for canonicalize_file_name, make_absolute_filename
Rik <octave@nomad.inbox5.com>
parents:
14429
diff
changeset
|
1616 Return the canonical name of file @var{fname}. If the file does not exist\n\ |
67b6b47a22f6
doc: Clarify docstrings for canonicalize_file_name, make_absolute_filename
Rik <octave@nomad.inbox5.com>
parents:
14429
diff
changeset
|
1617 the empty string (\"\") is returned.\n\ |
67b6b47a22f6
doc: Clarify docstrings for canonicalize_file_name, make_absolute_filename
Rik <octave@nomad.inbox5.com>
parents:
14429
diff
changeset
|
1618 @seealso{make_absolute_filename, is_absolute_filename, is_rooted_relative_filename}\n\ |
5138 | 1619 @end deftypefn") |
1620 { | |
1621 octave_value_list retval; | |
1622 | |
1623 if (args.length () == 1) | |
1624 { | |
1625 std::string name = args(0).string_value (); | |
1626 | |
1627 if (! error_state) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
1628 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
1629 std::string msg; |
5138 | 1630 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
1631 std::string result = octave_canonicalize_file_name (name, msg); |
5138 | 1632 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
1633 retval(2) = msg; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
1634 retval(1) = msg.empty () ? 0 : -1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
1635 retval(0) = result; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
1636 } |
5138 | 1637 else |
12483
7a5aacf65f81
Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents:
12212
diff
changeset
|
1638 error ("canonicalize_file_name: NAME must be a character string"); |
5138 | 1639 } |
1640 else | |
5823 | 1641 print_usage (); |
5138 | 1642 |
1643 return retval; | |
1644 } | |
1645 | |
5749 | 1646 static octave_value |
7924 | 1647 const_value (const octave_value_list& args, int val) |
5749 | 1648 { |
1649 octave_value retval; | |
1650 | |
1651 int nargin = args.length (); | |
1652 | |
1653 if (nargin == 0) | |
1654 retval = val; | |
1655 else | |
5823 | 1656 print_usage (); |
5749 | 1657 |
1658 return retval; | |
1659 } | |
1660 | |
2075 | 1661 #if !defined (O_NONBLOCK) && defined (O_NDELAY) |
1662 #define O_NONBLOCK O_NDELAY | |
1663 #endif | |
1664 | |
5749 | 1665 DEFUNX ("F_DUPFD", FF_DUPFD, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1666 "-*- texinfo -*-\n\ |
5749 | 1667 @deftypefn {Built-in Function} {} F_DUPFD ()\n\ |
14171
2ced2f59f523
doc: miscellaneous documentation improvements
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
1668 Return the numerical value to pass to @code{fcntl} to return a\n\ |
5749 | 1669 duplicate file descriptor.\n\ |
1670 @seealso{fcntl, F_GETFD, F_GETFL, F_SETFD, F_SETFL}\n\ | |
1671 @end deftypefn") | |
2075 | 1672 { |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1673 #if defined (F_DUPFD) |
7924 | 1674 return const_value (args, F_DUPFD); |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1675 #else |
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1676 error ("F_DUPFD: not available on this system"); |
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1677 return octave_value (); |
2075 | 1678 #endif |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1679 } |
2075 | 1680 |
5749 | 1681 DEFUNX ("F_GETFD", FF_GETFD, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1682 "-*- texinfo -*-\n\ |
5749 | 1683 @deftypefn {Built-in Function} {} F_GETFD ()\n\ |
14171
2ced2f59f523
doc: miscellaneous documentation improvements
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
1684 Return the numerical value to pass to @code{fcntl} to return the\n\ |
5749 | 1685 file descriptor flags.\n\ |
5333 | 1686 @seealso{fcntl, F_DUPFD, F_GETFL, F_SETFD, F_SETFL}\n\ |
5749 | 1687 @end deftypefn") |
1688 { | |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1689 #if defined (F_GETFD) |
7924 | 1690 return const_value (args, F_GETFD); |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1691 #else |
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1692 error ("F_GETFD: not available on this system"); |
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1693 return octave_value (); |
2075 | 1694 #endif |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1695 } |
2075 | 1696 |
5749 | 1697 DEFUNX ("F_GETFL", FF_GETFL, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1698 "-*- texinfo -*-\n\ |
5749 | 1699 @deftypefn {Built-in Function} {} F_GETFL ()\n\ |
14171
2ced2f59f523
doc: miscellaneous documentation improvements
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
1700 Return the numerical value to pass to @code{fcntl} to return the\n\ |
5749 | 1701 file status flags.\n\ |
5333 | 1702 @seealso{fcntl, F_DUPFD, F_GETFD, F_SETFD, F_SETFL}\n\ |
5749 | 1703 @end deftypefn") |
1704 { | |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1705 #if defined (F_GETFL) |
7924 | 1706 return const_value (args, F_GETFL); |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1707 #else |
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1708 error ("F_GETFL: not available on this system"); |
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1709 return octave_value (); |
2075 | 1710 #endif |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1711 } |
2075 | 1712 |
5749 | 1713 DEFUNX ("F_SETFD", FF_SETFD, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1714 "-*- texinfo -*-\n\ |
5749 | 1715 @deftypefn {Built-in Function} {} F_SETFD ()\n\ |
14171
2ced2f59f523
doc: miscellaneous documentation improvements
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
1716 Return the numerical value to pass to @code{fcntl} to set the file\n\ |
5749 | 1717 descriptor flags.\n\ |
5333 | 1718 @seealso{fcntl, F_DUPFD, F_GETFD, F_GETFL, F_SETFL}\n\ |
5749 | 1719 @end deftypefn") |
1720 { | |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1721 #if defined (F_SETFD) |
7924 | 1722 return const_value (args, F_SETFD); |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1723 #else |
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1724 error ("F_SETFD: not available on this system"); |
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1725 return octave_value (); |
2075 | 1726 #endif |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1727 } |
2075 | 1728 |
5749 | 1729 DEFUNX ("F_SETFL", FF_SETFL, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1730 "-*- texinfo -*-\n\ |
5749 | 1731 @deftypefn {Built-in Function} {} F_SETFL ()\n\ |
14171
2ced2f59f523
doc: miscellaneous documentation improvements
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
1732 Return the numerical value to pass to @code{fcntl} to set the file\n\ |
5749 | 1733 status flags.\n\ |
5333 | 1734 @seealso{fcntl, F_DUPFD, F_GETFD, F_GETFL, F_SETFD}\n\ |
5749 | 1735 @end deftypefn") |
1736 { | |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1737 #if defined (F_SETFL) |
7924 | 1738 return const_value (args, F_SETFL); |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1739 #else |
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1740 error ("F_SETFL: not available on this system"); |
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1741 return octave_value (); |
2075 | 1742 #endif |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1743 } |
2075 | 1744 |
5749 | 1745 DEFUNX ("O_APPEND", FO_APPEND, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1746 "-*- texinfo -*-\n\ |
5749 | 1747 @deftypefn {Built-in Function} {} O_APPEND ()\n\ |
1748 Return the numerical value of the file status flag that may be\n\ | |
1749 returned by @code{fcntl} to indicate each write operation appends,\n\ | |
11152
39ae406df598
Improve docstrings for functions found in undocumented list.
Rik <octave@nomad.inbox5.com>
parents:
11006
diff
changeset
|
1750 or that may be passed to @code{fcntl} to set the write mode to append.\n\ |
5333 | 1751 @seealso{fcntl, O_ASYNC, O_CREAT, O_EXCL, O_NONBLOCK, O_RDONLY, O_RDWR, O_SYNC, O_TRUNC, O_WRONLY}\n\ |
5749 | 1752 @end deftypefn") |
1753 { | |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1754 #if defined (O_APPEND) |
7924 | 1755 return const_value (args, O_APPEND); |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1756 #else |
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1757 error ("O_APPEND: not available on this system"); |
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1758 return octave_value (); |
2075 | 1759 #endif |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1760 } |
2075 | 1761 |
5749 | 1762 DEFUNX ("O_ASYNC", FO_ASYNC, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1763 "-*- texinfo -*-\n\ |
5749 | 1764 @deftypefn {Built-in Function} {} O_ASYNC ()\n\ |
1765 Return the numerical value of the file status flag that may be\n\ | |
1766 returned by @code{fcntl} to indicate asynchronous I/O.\n\ | |
5333 | 1767 @seealso{fcntl, O_APPEND, O_CREAT, O_EXCL, O_NONBLOCK, O_RDONLY, O_RDWR, O_SYNC, O_TRUNC, O_WRONLY}\n\ |
5749 | 1768 @end deftypefn") |
1769 { | |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1770 #if defined (O_ASYNC) |
7924 | 1771 return const_value (args, O_ASYNC); |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1772 #else |
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1773 error ("O_ASYNC: not available on this system"); |
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1774 return octave_value (); |
2669 | 1775 #endif |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1776 } |
2669 | 1777 |
5749 | 1778 DEFUNX ("O_CREAT", FO_CREAT, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1779 "-*- texinfo -*-\n\ |
5749 | 1780 @deftypefn {Built-in Function} {} O_CREAT ()\n\ |
1781 Return the numerical value of the file status flag that may be\n\ | |
1782 returned by @code{fcntl} to indicate that a file should be\n\ | |
1783 created if it does not exist.\n\ | |
5333 | 1784 @seealso{fcntl, O_APPEND, O_ASYNC, O_EXCL, O_NONBLOCK, O_RDONLY, O_RDWR, O_SYNC, O_TRUNC, O_WRONLY}\n\ |
5749 | 1785 @end deftypefn") |
1786 { | |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1787 #if defined (O_CREAT) |
7924 | 1788 return const_value (args, O_CREAT); |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1789 #else |
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1790 error ("O_CREAT: not available on this system"); |
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1791 return octave_value (); |
2075 | 1792 #endif |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1793 } |
2075 | 1794 |
5749 | 1795 DEFUNX ("O_EXCL", FO_EXCL, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1796 "-*- texinfo -*-\n\ |
5749 | 1797 @deftypefn {Built-in Function} {} O_EXCL ()\n\ |
1798 Return the numerical value of the file status flag that may be\n\ | |
1799 returned by @code{fcntl} to indicate that file locking is used.\n\ | |
5333 | 1800 @seealso{fcntl, O_APPEND, O_ASYNC, O_CREAT, O_NONBLOCK, O_RDONLY, O_RDWR, O_SYNC, O_TRUNC, O_WRONLY}\n\ |
5749 | 1801 @end deftypefn") |
1802 { | |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1803 #if defined (O_EXCL) |
7924 | 1804 return const_value (args, O_EXCL); |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1805 #else |
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1806 error ("O_EXCL: not available on this system"); |
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1807 return octave_value (); |
2075 | 1808 #endif |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1809 } |
2075 | 1810 |
5749 | 1811 DEFUNX ("O_NONBLOCK", FO_NONBLOCK, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1812 "-*- texinfo -*-\n\ |
5749 | 1813 @deftypefn {Built-in Function} {} O_NONBLOCK ()\n\ |
1814 Return the numerical value of the file status flag that may be\n\ | |
1815 returned by @code{fcntl} to indicate that non-blocking I/O is in use,\n\ | |
1816 or that may be passsed to @code{fcntl} to set non-blocking I/O.\n\ | |
5333 | 1817 @seealso{fcntl, O_APPEND, O_ASYNC, O_CREAT, O_EXCL, O_RDONLY, O_RDWR, O_SYNC, O_TRUNC, O_WRONLY}\n\ |
5749 | 1818 @end deftypefn") |
1819 { | |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1820 #if defined (O_NONBLOCK) |
7924 | 1821 return const_value (args, O_NONBLOCK); |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1822 #else |
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1823 error ("O_NONBLOCK: not available on this system"); |
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1824 return octave_value (); |
2075 | 1825 #endif |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1826 } |
2075 | 1827 |
5749 | 1828 DEFUNX ("O_RDONLY", FO_RDONLY, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1829 "-*- texinfo -*-\n\ |
5749 | 1830 @deftypefn {Built-in Function} {} O_RDONLY ()\n\ |
1831 Return the numerical value of the file status flag that may be\n\ | |
1832 returned by @code{fcntl} to indicate that a file is open for\n\ | |
1833 reading only.\n\ | |
5333 | 1834 @seealso{fcntl, O_APPEND, O_ASYNC, O_CREAT, O_EXCL, O_NONBLOCK, O_RDWR, O_SYNC, O_TRUNC, O_WRONLY}\n\ |
5749 | 1835 @end deftypefn") |
1836 { | |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1837 #if defined (O_RDONLY) |
7924 | 1838 return const_value (args, O_RDONLY); |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1839 #else |
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1840 error ("O_RDONLY: not available on this system"); |
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1841 return octave_value (); |
2075 | 1842 #endif |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1843 } |
2075 | 1844 |
5749 | 1845 DEFUNX ("O_RDWR", FO_RDWR, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1846 "-*- texinfo -*-\n\ |
5749 | 1847 @deftypefn {Built-in Function} {} O_RDWR ()\n\ |
1848 Return the numerical value of the file status flag that may be\n\ | |
1849 returned by @code{fcntl} to indicate that a file is open for both\n\ | |
1850 reading and writing.\n\ | |
5333 | 1851 @seealso{fcntl, O_APPEND, O_ASYNC, O_CREAT, O_EXCL, O_NONBLOCK, O_RDONLY, O_SYNC, O_TRUNC, O_WRONLY}\n\ |
5749 | 1852 @end deftypefn") |
1853 { | |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1854 #if defined (O_RDWR) |
7924 | 1855 return const_value (args, O_RDWR); |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1856 #else |
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1857 error ("O_RDWR: not available on this system"); |
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1858 return octave_value (); |
2075 | 1859 #endif |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1860 } |
2075 | 1861 |
5749 | 1862 DEFUNX ("O_SYNC", FO_SYNC, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1863 "-*- texinfo -*-\n\ |
5749 | 1864 @deftypefn {Built-in Function} {} O_SYNC ()\n\ |
1865 Return the numerical value of the file status flag that may be\n\ | |
1866 returned by @code{fcntl} to indicate that a file is open for\n\ | |
1867 synchronous I/O.\n\ | |
5333 | 1868 @seealso{fcntl, O_APPEND, O_ASYNC, O_CREAT, O_EXCL, O_NONBLOCK, O_RDONLY, O_RDWR, O_TRUNC, O_WRONLY}\n\ |
5749 | 1869 @end deftypefn") |
1870 { | |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1871 #if defined (O_SYNC) |
7924 | 1872 return const_value (args, O_SYNC); |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1873 #else |
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1874 error ("O_SYNC: not available on this system"); |
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1875 return octave_value (); |
2669 | 1876 #endif |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1877 } |
2669 | 1878 |
5749 | 1879 DEFUNX ("O_TRUNC", FO_TRUNC, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1880 "-*- texinfo -*-\n\ |
11572
7d6d8c1e471f
Grammarcheck Texinfo for files in src directory.
Rik <octave@nomad.inbox5.com>
parents:
11546
diff
changeset
|
1881 @deftypefn {Built-in Function} O_TRUNC ()\n\ |
5749 | 1882 Return the numerical value of the file status flag that may be\n\ |
1883 returned by @code{fcntl} to indicate that if file exists, it should\n\ | |
1884 be truncated when writing.\n\ | |
5333 | 1885 @seealso{fcntl, O_APPEND, O_ASYNC, O_CREAT, O_EXCL, O_NONBLOCK, O_RDONLY, O_RDWR, O_SYNC, O_WRONLY}\n\ |
5749 | 1886 @end deftypefn") |
1887 { | |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1888 #if defined (O_TRUNC) |
7924 | 1889 return const_value (args, O_TRUNC); |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1890 #else |
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1891 error ("O_TRUNC: not available on this system"); |
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1892 return octave_value (); |
2075 | 1893 #endif |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1894 } |
2075 | 1895 |
5749 | 1896 DEFUNX ("O_WRONLY", FO_WRONLY, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1897 "-*- texinfo -*-\n\ |
5749 | 1898 @deftypefn {Built-in Function} {} O_WRONLY ()\n\ |
1899 Return the numerical value of the file status flag that may be\n\ | |
1900 returned by @code{fcntl} to indicate that a file is open for\n\ | |
1901 writing only.\n\ | |
5333 | 1902 @seealso{fcntl, O_APPEND, O_ASYNC, O_CREAT, O_EXCL, O_NONBLOCK, O_RDONLY, O_RDWR, O_SYNC, O_TRUNC}\n\ |
5749 | 1903 @end deftypefn") |
1904 { | |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1905 #if defined (O_WRONLY) |
7924 | 1906 return const_value (args, O_WRONLY); |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1907 #else |
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1908 error ("O_WRONLY: not available on this system"); |
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1909 return octave_value (); |
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1910 #endif |
5749 | 1911 } |
3446 | 1912 |
5453 | 1913 #if !defined (WNOHANG) |
1914 #define WNOHANG 0 | |
1915 #endif | |
1916 | |
5749 | 1917 DEFUNX ("WNOHANG", FWNOHANG, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1918 "-*- texinfo -*-\n\ |
5749 | 1919 @deftypefn {Built-in Function} {} WNOHANG ()\n\ |
1920 Return the numerical value of the option argument that may be\n\ | |
1921 passed to @code{waitpid} to indicate that it should return its\n\ | |
1922 status immediately instead of waiting for a process to exit.\n\ | |
5453 | 1923 @seealso{waitpid, WUNTRACED, WCONTINUE}\n\ |
5749 | 1924 @end deftypefn") |
1925 { | |
7924 | 1926 return const_value (args, WNOHANG); |
5749 | 1927 } |
5453 | 1928 |
1929 #if !defined (WUNTRACED) | |
1930 #define WUNTRACED 0 | |
1931 #endif | |
1932 | |
5749 | 1933 DEFUNX ("WUNTRACED", FWUNTRACED, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1934 "-*- texinfo -*-\n\ |
5749 | 1935 @deftypefn {Built-in Function} {} WUNTRACED ()\n\ |
1936 Return the numerical value of the option argument that may be\n\ | |
1937 passed to @code{waitpid} to indicate that it should also return\n\ | |
1938 if the child process has stopped but is not traced via the\n\ | |
1939 @code{ptrace} system call\n\ | |
5453 | 1940 @seealso{waitpid, WNOHANG, WCONTINUE}\n\ |
5749 | 1941 @end deftypefn") |
1942 { | |
7924 | 1943 return const_value (args, WUNTRACED); |
5749 | 1944 } |
5453 | 1945 |
1946 #if !defined (WCONTINUE) | |
1947 #define WCONTINUE 0 | |
1948 #endif | |
1949 | |
5749 | 1950 DEFUNX ("WCONTINUE", FWCONTINUE, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1951 "-*- texinfo -*-\n\ |
9724
f22bbc5d56e9
Fix various incorrect usages of TeXinfo deffn and deftypefn macros
Rik <rdrider0-list@yahoo.com>
parents:
9564
diff
changeset
|
1952 @deftypefn {Built-in Function} {} WCONTINUE ()\n\ |
5749 | 1953 Return the numerical value of the option argument that may be\n\ |
1954 passed to @code{waitpid} to indicate that it should also return\n\ | |
1955 if a stopped child has been resumed by delivery of a @code{SIGCONT}\n\ | |
1956 signal.\n\ | |
5453 | 1957 @seealso{waitpid, WNOHANG, WUNTRACED}\n\ |
5749 | 1958 @end deftypefn") |
1959 { | |
7924 | 1960 return const_value (args, WCONTINUE); |
2075 | 1961 } |