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