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