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