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