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