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