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