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