annotate libinterp/corefcn/syscalls.cc @ 21911:c66c156e1d1d

hide fcntl.h header * liboctave/wrappers/fcntl-wrappers.c, liboctave/wrappers/fcntl-wrappers.h, liboctave/wrappers/octave-popen2.c, liboctave/wrappers/octave-popen2.h: New files. * liboctave/wrappers/module.mk: Update. * file-io.cc, syscalls.cc, octave.cc, lo-sysdep.cc, oct-syscalls.cc: Use new wrapper functions. Don't include fcntl.h.
author John W. Eaton <jwe@octave.org>
date Wed, 15 Jun 2016 13:51:00 -0400
parents 25493c55d976
children ecfcc8527661
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1 /*
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
2
19697
4197fc428c7d maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents: 19403
diff changeset
3 Copyright (C) 1996-2015 John W. Eaton
10521
4d1fc073fbb7 add some missing copyright stmts
Jaroslav Hajek <highegg@gmail.com>
parents: 10336
diff changeset
4 Copyright (C) 2010 VZLU Prague
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
5
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
6 This file is part of Octave.
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
7
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
8 Octave is free software; you can redistribute it and/or modify it
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
9 under the terms of the GNU General Public License as published by the
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 7001
diff changeset
10 Free Software Foundation; either version 3 of the License, or (at your
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 7001
diff changeset
11 option) any later version.
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
12
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
13 Octave is distributed in the hope that it will be useful, but WITHOUT
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
16 for more details.
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
17
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
18 You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 7001
diff changeset
19 along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 7001
diff changeset
20 <http://www.gnu.org/licenses/>.
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
21
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
22 */
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
23
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
24 // Thomas Baier <baier@ci.tuwien.ac.at> added the original versions of
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
25 // the following functions:
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
26 //
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
27 // mkfifo unlink waitpid
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
28
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21672
diff changeset
29 #if defined (HAVE_CONFIG_H)
21301
40de9f8f23a6 Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents: 21200
diff changeset
30 # include "config.h"
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
31 #endif
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
32
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
33 #include <cstdio>
2669
c821858188b6 [project @ 1997-02-13 18:25:39 by jwe]
jwe
parents: 2475
diff changeset
34 #include <cstring>
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
35
17236
6a6e3f1a824c save history on exec (bug #39734)
John W. Eaton <jwe@octave.org>
parents: 15221
diff changeset
36 #include "cmd-hist.h"
21911
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
37 #include "fcntl-wrappers.h"
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2902
diff changeset
38 #include "file-ops.h"
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2902
diff changeset
39 #include "file-stat.h"
11006
aca961a3f387 provide gethostname function
John W. Eaton <jwe@octave.org>
parents: 10840
diff changeset
40 #include "oct-env.h"
2937
9d26524e2869 [project @ 1997-05-06 05:49:53 by jwe]
jwe
parents: 2926
diff changeset
41 #include "oct-syscalls.h"
5547
8b0b36c2dc0c [project @ 2005-11-29 17:41:33 by jwe]
jwe
parents: 5476
diff changeset
42 #include "oct-uname.h"
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2902
diff changeset
43
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
44 #include "defun.h"
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
45 #include "error.h"
21100
e39e05d90788 Switch gripe_XXX to either err_XXX or warn_XXX naming scheme.
Rik <rik@octave.org>
parents: 21055
diff changeset
46 #include "errwarn.h"
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
47 #include "lo-utils.h"
17236
6a6e3f1a824c save history on exec (bug #39734)
John W. Eaton <jwe@octave.org>
parents: 15221
diff changeset
48 #include "oct-hist.h"
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
49 #include "oct-map.h"
20940
48b2ad5ee801 maint: Rename oct-obj.[cc|h] to ovl.[cc|h] for clarity.
Rik <rik@octave.org>
parents: 20939
diff changeset
50 #include "ovl.h"
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
51 #include "oct-stdstrm.h"
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
52 #include "oct-stream.h"
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
53 #include "sysdep.h"
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
54 #include "utils.h"
2366
c90105b99479 [project @ 1996-10-11 23:22:27 by jwe]
jwe
parents: 2305
diff changeset
55 #include "variables.h"
6321
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 5872
diff changeset
56 #include "input.h"
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
57
10762
d53eb6249892 use scalar map in some syscalls
Jaroslav Hajek <highegg@gmail.com>
parents: 10521
diff changeset
58 static octave_scalar_map
21737
ab6c639f0678 finish previous changeset (0504351a45e6).
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
59 mk_stat_map (const octave::sys::base_file_stat& fs)
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
60 {
10762
d53eb6249892 use scalar map in some syscalls
Jaroslav Hajek <highegg@gmail.com>
parents: 10521
diff changeset
61 octave_scalar_map m;
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
62
4675
f6d6335c08f6 [project @ 2003-12-16 05:11:26 by jwe]
jwe
parents: 4371
diff changeset
63 m.assign ("dev", static_cast<double> (fs.dev ()));
f6d6335c08f6 [project @ 2003-12-16 05:11:26 by jwe]
jwe
parents: 4371
diff changeset
64 m.assign ("ino", fs.ino ());
5476
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
65 m.assign ("mode", fs.mode ());
4675
f6d6335c08f6 [project @ 2003-12-16 05:11:26 by jwe]
jwe
parents: 4371
diff changeset
66 m.assign ("modestr", fs.mode_as_string ());
f6d6335c08f6 [project @ 2003-12-16 05:11:26 by jwe]
jwe
parents: 4371
diff changeset
67 m.assign ("nlink", fs.nlink ());
f6d6335c08f6 [project @ 2003-12-16 05:11:26 by jwe]
jwe
parents: 4371
diff changeset
68 m.assign ("uid", fs.uid ());
f6d6335c08f6 [project @ 2003-12-16 05:11:26 by jwe]
jwe
parents: 4371
diff changeset
69 m.assign ("gid", fs.gid ());
3887
7da18459c08b [project @ 2002-04-04 00:44:21 by jwe]
jwe
parents: 3715
diff changeset
70 #if defined (HAVE_STRUCT_STAT_ST_RDEV)
4675
f6d6335c08f6 [project @ 2003-12-16 05:11:26 by jwe]
jwe
parents: 4371
diff changeset
71 m.assign ("rdev", static_cast<double> (fs.rdev ()));
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
72 #endif
4675
f6d6335c08f6 [project @ 2003-12-16 05:11:26 by jwe]
jwe
parents: 4371
diff changeset
73 m.assign ("size", fs.size ());
f6d6335c08f6 [project @ 2003-12-16 05:11:26 by jwe]
jwe
parents: 4371
diff changeset
74 m.assign ("atime", fs.atime ());
f6d6335c08f6 [project @ 2003-12-16 05:11:26 by jwe]
jwe
parents: 4371
diff changeset
75 m.assign ("mtime", fs.mtime ());
f6d6335c08f6 [project @ 2003-12-16 05:11:26 by jwe]
jwe
parents: 4371
diff changeset
76 m.assign ("ctime", fs.ctime ());
3887
7da18459c08b [project @ 2002-04-04 00:44:21 by jwe]
jwe
parents: 3715
diff changeset
77 #if defined (HAVE_STRUCT_STAT_ST_BLKSIZE)
4675
f6d6335c08f6 [project @ 2003-12-16 05:11:26 by jwe]
jwe
parents: 4371
diff changeset
78 m.assign ("blksize", fs.blksize ());
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
79 #endif
3887
7da18459c08b [project @ 2002-04-04 00:44:21 by jwe]
jwe
parents: 3715
diff changeset
80 #if defined (HAVE_STRUCT_STAT_ST_BLOCKS)
4675
f6d6335c08f6 [project @ 2003-12-16 05:11:26 by jwe]
jwe
parents: 4371
diff changeset
81 m.assign ("blocks", fs.blocks ());
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
82 #endif
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
83
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
84 return m;
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
85 }
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
86
10336
1603dfe72933 obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
87 static octave_value_list
21737
ab6c639f0678 finish previous changeset (0504351a45e6).
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
88 mk_stat_result (const octave::sys::base_file_stat& fs)
10336
1603dfe72933 obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
89 {
1603dfe72933 obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
90 if (fs)
20887
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
91 return ovl (octave_value (mk_stat_map (fs)), 0, "");
10336
1603dfe72933 obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
92 else
20887
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
93 return ovl (Matrix (), -1, fs.error ());
10336
1603dfe72933 obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
94 }
1603dfe72933 obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
95
10299
c992efc0c2fa use DEFUNX instead of DEFUN for all functions in syscalls.cc
John W. Eaton <jwe@octave.org>
parents: 10259
diff changeset
96 DEFUNX ("dup2", Fdup2, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
97 "-*- texinfo -*-\n\
20853
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20819
diff changeset
98 @deftypefn {} {[@var{fid}, @var{msg}] =} dup2 (@var{old}, @var{new})\n\
2669
c821858188b6 [project @ 1997-02-13 18:25:39 by jwe]
jwe
parents: 2475
diff changeset
99 Duplicate a file descriptor.\n\
c821858188b6 [project @ 1997-02-13 18:25:39 by jwe]
jwe
parents: 2475
diff changeset
100 \n\
20172
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
101 If successful, @var{fid} is greater than zero and contains the new file ID@.\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
102 Otherwise, @var{fid} is negative and @var{msg} contains a system-dependent\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
103 error message.\n\
19109
e90bfaadb489 doc: Increase seealso links between low level C IO functions.
Rik <rik@octave.org>
parents: 18112
diff changeset
104 @seealso{fopen, fclose, fcntl}\n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
105 @end deftypefn")
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
106 {
20819
f428cbe7576f eliminate unnecessary uses of nargin
John W. Eaton <jwe@octave.org>
parents: 20800
diff changeset
107 if (args.length () != 2)
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
108 print_usage ();
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
109
20887
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
110 octave_stream old_stream = octave_stream_list::lookup (args(0), "dup2");
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
111
20887
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
112 octave_stream new_stream = octave_stream_list::lookup (args(1), "dup2");
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
113
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
114 int i_old = old_stream.file_number ();
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
115 int i_new = new_stream.file_number ();
2669
c821858188b6 [project @ 1997-02-13 18:25:39 by jwe]
jwe
parents: 2475
diff changeset
116
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
117 if (i_old >= 0 && i_new >= 0)
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
118 {
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
119 std::string msg;
3341
14cfc9475fe4 [project @ 1999-11-05 08:11:58 by jwe]
jwe
parents: 3340
diff changeset
120
21727
e0da98857c19 rename octave::syscalls namespace to octave::sys
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
121 int status = octave::sys::dup2 (i_old, i_new, msg);
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
122
20887
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
123 return ovl (status, msg);
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
124 }
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
125 else
20887
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
126 return ovl (-1, "");
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
127 }
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
128
10299
c992efc0c2fa use DEFUNX instead of DEFUN for all functions in syscalls.cc
John W. Eaton <jwe@octave.org>
parents: 10259
diff changeset
129 DEFUNX ("exec", Fexec, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
130 "-*- texinfo -*-\n\
20853
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20819
diff changeset
131 @deftypefn {} {[@var{err}, @var{msg}] =} exec (@var{file}, @var{args})\n\
20172
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
132 Replace current process with a new process.\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
133 \n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
134 Calling @code{exec} without first calling @code{fork} will terminate your\n\
20181
aa36fb998a4d maint: Remove unnecessary whitespace at end of lines.
Rik <rik@octave.org>
parents: 20172
diff changeset
135 current Octave process and replace it with the program named by @var{file}.\n\
20172
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
136 For example,\n\
2669
c821858188b6 [project @ 1997-02-13 18:25:39 by jwe]
jwe
parents: 2475
diff changeset
137 \n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
138 @example\n\
21671
32a6d948fea7 doc: Fix typo in exec docstring.
Rik <rik@octave.org>
parents: 20198
diff changeset
139 exec (\"ls\", \"-l\")\n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
140 @end example\n\
2669
c821858188b6 [project @ 1997-02-13 18:25:39 by jwe]
jwe
parents: 2475
diff changeset
141 \n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
142 @noindent\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
143 will run @code{ls} and return you to your shell prompt.\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
144 \n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
145 If successful, @code{exec} does not return. If @code{exec} does return,\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
146 @var{err} will be nonzero, and @var{msg} will contain a system-dependent\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
147 error message.\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
148 @end deftypefn")
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
149 {
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
150 int nargin = args.length ();
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
151
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
152 if (nargin < 1 || nargin > 2)
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
153 print_usage ();
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
154
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
155 std::string exec_file = args(0).xstring_value ("exec: FILE must be a string");
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
156
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
157 string_vector exec_args;
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
158
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
159 if (nargin == 2)
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
160 {
20990
fc9cca99b2de Deprecate all_strings, replace with string_vector_value.
Rik <rik@octave.org>
parents: 20956
diff changeset
161 string_vector tmp = args(1).xstring_vector_value ("exec: all arguments must be strings");
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
162
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
163 int len = tmp.numel ();
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
164
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
165 exec_args.resize (len + 1);
2937
9d26524e2869 [project @ 1997-05-06 05:49:53 by jwe]
jwe
parents: 2926
diff changeset
166
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
167 exec_args[0] = exec_file;
2669
c821858188b6 [project @ 1997-02-13 18:25:39 by jwe]
jwe
parents: 2475
diff changeset
168
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
169 for (int i = 0; i < len; i++)
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
170 exec_args[i+1] = tmp[i];
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
171 }
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
172 else
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
173 {
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
174 exec_args.resize (1);
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
175
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
176 exec_args[0] = exec_file;
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
177 }
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
178
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
179 octave_history_write_timestamp ();
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
180
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21737
diff changeset
181 if (! octave::command_history::ignoring_entries ())
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21737
diff changeset
182 octave::command_history::clean_up_and_save ();
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
183
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
184 std::string msg;
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
185
21727
e0da98857c19 rename octave::syscalls namespace to octave::sys
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
186 int status = octave::sys::execvp (exec_file, exec_args, msg);
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
187
20887
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
188 return ovl (status, msg);
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
189 }
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
190
10299
c992efc0c2fa use DEFUNX instead of DEFUN for all functions in syscalls.cc
John W. Eaton <jwe@octave.org>
parents: 10259
diff changeset
191 DEFUNX ("popen2", Fpopen2, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
192 "-*- texinfo -*-\n\
20853
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20819
diff changeset
193 @deftypefn {} {[@var{in}, @var{out}, @var{pid}] =} popen2 (@var{command}, @var{args})\n\
20172
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
194 Start a subprocess with two-way communication.\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
195 \n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
196 The name of the process is given by @var{command}, and @var{args} is an\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
197 array of strings containing options for the command.\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
198 \n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
199 The file identifiers for the input and output streams of the subprocess are\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
200 returned in @var{in} and @var{out}. If execution of the command is\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
201 successful, @var{pid} contains the process ID of the subprocess. Otherwise,\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
202 @var{pid} is @minus{}1.\n\
6321
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 5872
diff changeset
203 \n\
10840
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10791
diff changeset
204 For example:\n\
6321
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 5872
diff changeset
205 \n\
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 5872
diff changeset
206 @example\n\
6923
1fcee6e2c4d3 [project @ 2007-09-25 16:57:12 by jwe]
jwe
parents: 6678
diff changeset
207 [in, out, pid] = popen2 (\"sort\", \"-r\");\n\
6321
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 5872
diff changeset
208 fputs (in, \"these\\nare\\nsome\\nstrings\\n\");\n\
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 5872
diff changeset
209 fclose (in);\n\
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 5872
diff changeset
210 EAGAIN = errno (\"EAGAIN\");\n\
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 5872
diff changeset
211 done = false;\n\
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 5872
diff changeset
212 do\n\
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 5872
diff changeset
213 s = fgets (out);\n\
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 5872
diff changeset
214 if (ischar (s))\n\
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 5872
diff changeset
215 fputs (stdout, s);\n\
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 5872
diff changeset
216 elseif (errno () == EAGAIN)\n\
20923
58263bea2fdf Unified "sleep" functions to "octave_sleep" in C++ and "pause" in Octave.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 20898
diff changeset
217 pause (0.1);\n\
6321
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 5872
diff changeset
218 fclear (out);\n\
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 5872
diff changeset
219 else\n\
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 5872
diff changeset
220 done = true;\n\
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 5872
diff changeset
221 endif\n\
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 5872
diff changeset
222 until (done)\n\
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 5872
diff changeset
223 fclose (out);\n\
9563
f5c28d8f5147 syscalls.cc: Recommend waitpid() in popen2() documentation.
Rob Mahurin <rob@utk.edu>
parents: 9209
diff changeset
224 waitpid (pid);\n\
14360
97883071e8e4 doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents: 14171
diff changeset
225 \n\
97883071e8e4 doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents: 14171
diff changeset
226 @print{} these\n\
97883071e8e4 doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents: 14171
diff changeset
227 @print{} strings\n\
97883071e8e4 doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents: 14171
diff changeset
228 @print{} some\n\
97883071e8e4 doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents: 14171
diff changeset
229 @print{} are\n\
6321
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 5872
diff changeset
230 @end example\n\
9563
f5c28d8f5147 syscalls.cc: Recommend waitpid() in popen2() documentation.
Rob Mahurin <rob@utk.edu>
parents: 9209
diff changeset
231 \n\
21547
ad0599a0acc6 doc: Wrap C++ docstrings to 79 characters + newline (80 total).
Rik <rik@octave.org>
parents: 21343
diff changeset
232 Note that @code{popen2}, unlike @code{popen}, will not @nospell{\"reap\"}\n\
ad0599a0acc6 doc: Wrap C++ docstrings to 79 characters + newline (80 total).
Rik <rik@octave.org>
parents: 21343
diff changeset
233 the child process. If you don't use @code{waitpid} to check the child's\n\
9564
9e4333169eae fix typo in last patch
Jaroslav Hajek <highegg@gmail.com>
parents: 9563
diff changeset
234 exit status, it will linger until Octave exits.\n\
17968
43c199e83ed7 Reap child process in popen2 %!test block.
Rik <rik@octave.org>
parents: 17951
diff changeset
235 @seealso{popen, waitpid}\n\
6321
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 5872
diff changeset
236 @end deftypefn")
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 5872
diff changeset
237 {
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 5872
diff changeset
238 int nargin = args.length ();
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 5872
diff changeset
239
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
240 if (nargin < 1 || nargin > 3)
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
241 print_usage ();
6321
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 5872
diff changeset
242
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
243 std::string exec_file = args(0).xstring_value ("popen2: COMMAND argument must be a string");
6321
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 5872
diff changeset
244
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
245 string_vector arg_list;
6321
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 5872
diff changeset
246
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
247 if (nargin >= 2)
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
248 {
20990
fc9cca99b2de Deprecate all_strings, replace with string_vector_value.
Rik <rik@octave.org>
parents: 20956
diff changeset
249 string_vector tmp = args(1).xstring_vector_value ("popen2: all arguments must be strings");
6321
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 5872
diff changeset
250
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
251 int len = tmp.numel ();
6321
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 5872
diff changeset
252
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
253 arg_list.resize (len + 1);
6321
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 5872
diff changeset
254
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
255 arg_list[0] = exec_file;
20704
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20700
diff changeset
256
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
257 for (int i = 0; i < len; i++)
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
258 arg_list[i+1] = tmp[i];
6321
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 5872
diff changeset
259 }
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 5872
diff changeset
260 else
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
261 {
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
262 arg_list.resize (1);
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
263
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
264 arg_list[0] = exec_file;
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
265 }
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
266
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
267 bool sync_mode = (nargin == 3 ? args(2).bool_value () : false);
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
268
20887
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
269 int filedesc[2];
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
270 std::string msg;
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
271 pid_t pid;
6321
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 5872
diff changeset
272
21733
cb0fdd941d84 use namespace for system file_ops class
John W. Eaton <jwe@octave.org>
parents: 21732
diff changeset
273 pid = octave::sys::popen2 (exec_file, arg_list, sync_mode, filedesc,
cb0fdd941d84 use namespace for system file_ops class
John W. Eaton <jwe@octave.org>
parents: 21732
diff changeset
274 msg, interactive);
20887
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
275 if (pid < 0)
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
276 error (msg.c_str ());
6321
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 5872
diff changeset
277
20887
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
278 FILE *ifile = fdopen (filedesc[1], "r");
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
279 FILE *ofile = fdopen (filedesc[0], "w");
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
280
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
281 octave_stream is = octave_stdiostream::create (exec_file + "-in",
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
282 ifile,
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
283 std::ios::in);
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
284
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
285 octave_stream os = octave_stdiostream::create (exec_file + "-out",
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
286 ofile,
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
287 std::ios::out);
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
288
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
289 return ovl (octave_stream_list::insert (os),
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
290 octave_stream_list::insert (is),
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
291 pid);
6321
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 5872
diff changeset
292 }
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 5872
diff changeset
293
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 5872
diff changeset
294 /*
18022
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
295
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
296 %!test # UNIX-style test
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
297 %! if (isunix () || ismac ())
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
298 %! [in, out, pid] = popen2 ("sort", "-r");
14429
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
299 %! EAGAIN = errno ("EAGAIN");
18022
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
300 %! fputs (in, "these\nare\nsome\nstrings\n");
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
301 %! fclose (in);
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
302 %! done = false;
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
303 %! str = {};
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
304 %! idx = 0;
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
305 %! errs = 0;
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
306 %! do
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
307 %! if (ismac ()) # FIXME: Is this necessary?
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
308 %! errno (0);
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
309 %! endif
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
310 %! s = fgets (out);
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
311 %! if (ischar (s))
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
312 %! idx++;
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
313 %! str{idx} = s;
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
314 %! elseif (errno () == EAGAIN)
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
315 %! fclear (out);
20923
58263bea2fdf Unified "sleep" functions to "octave_sleep" in C++ and "pause" in Octave.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 20898
diff changeset
316 %! pause (0.1);
18022
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
317 %! if (++errs == 100)
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
318 %! done = true;
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
319 %! endif
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
320 %! else
6321
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 5872
diff changeset
321 %! done = true;
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 5872
diff changeset
322 %! endif
18022
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
323 %! until (done)
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
324 %! fclose (out);
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
325 %! waitpid (pid);
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
326 %! assert (str, {"these\n","strings\n","some\n","are\n"});
18022
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
327 %! endif
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
328
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
329 %!test # Windows-style test
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
330 %! if (ispc () && ! isunix ())
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
331 %! [in, out, pid] = popen2 ('C:\Windows\system32\sort.exe', "/R");
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
332 %! EAGAIN = errno ("EINVAL");
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
333 %! fputs (in, "these\r\nare\r\nsome\r\nstrings\r\n");
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
334 %! fclose (in);
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
335 %! done = false;
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
336 %! str = {};
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
337 %! idx = 0;
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
338 %! errs = 0;
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
339 %! do
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
340 %! errno (0);
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
341 %! s = fgets (out);
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
342 %! if (ischar (s))
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
343 %! idx++;
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
344 %! str{idx} = s;
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
345 %! elseif (errno () == EAGAIN)
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
346 %! fclear (out);
20923
58263bea2fdf Unified "sleep" functions to "octave_sleep" in C++ and "pause" in Octave.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 20898
diff changeset
347 %! pause (0.1);
18022
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
348 %! if (++errs == 100)
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
349 %! done = true;
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
350 %! endif
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
351 %! else
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
352 %! done = true;
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
353 %! endif
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
354 %! until (done)
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
355 %! fclose (out);
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
356 %! waitpid (pid);
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
357 %! assert (str, {"these\r\n","strings\r\n","some\r\n","are\r\n"});
14429
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
358 %! endif
18022
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
359
6321
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 5872
diff changeset
360 */
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 5872
diff changeset
361
10259
65b41bc71f09 use gnulib fcntl module
John W. Eaton <jwe@octave.org>
parents: 10252
diff changeset
362 DEFUNX ("fcntl", Ffcntl, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
363 "-*- texinfo -*-\n\
20853
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20819
diff changeset
364 @deftypefn {} {[@var{err}, @var{msg}] =} fcntl (@var{fid}, @var{request}, @var{arg})\n\
19109
e90bfaadb489 doc: Increase seealso links between low level C IO functions.
Rik <rik@octave.org>
parents: 18112
diff changeset
365 Change the properties of the open file @var{fid}.\n\
e90bfaadb489 doc: Increase seealso links between low level C IO functions.
Rik <rik@octave.org>
parents: 18112
diff changeset
366 \n\
e90bfaadb489 doc: Increase seealso links between low level C IO functions.
Rik <rik@octave.org>
parents: 18112
diff changeset
367 The following values may be passed as @var{request}:\n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
368 \n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
369 @vtable @code\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
370 @item F_DUPFD\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
371 Return a duplicate file descriptor.\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
372 \n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
373 @item F_GETFD\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
374 Return the file descriptor flags for @var{fid}.\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
375 \n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
376 @item F_SETFD\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
377 Set the file descriptor flags for @var{fid}.\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
378 \n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
379 @item F_GETFL\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
380 Return the file status flags for @var{fid}. The following codes may be\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
381 returned (some of the flags may be undefined on some systems).\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
382 \n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
383 @vtable @code\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
384 @item O_RDONLY\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
385 Open for reading only.\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
386 \n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
387 @item O_WRONLY\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
388 Open for writing only.\n\
2669
c821858188b6 [project @ 1997-02-13 18:25:39 by jwe]
jwe
parents: 2475
diff changeset
389 \n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
390 @item O_RDWR\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
391 Open for reading and writing.\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
392 \n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
393 @item O_APPEND\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
394 Append on each write.\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
395 \n\
5040
b6ff3a0d3d17 [project @ 2004-09-27 13:50:01 by jwe]
jwe
parents: 4928
diff changeset
396 @item O_CREAT\n\
b6ff3a0d3d17 [project @ 2004-09-27 13:50:01 by jwe]
jwe
parents: 4928
diff changeset
397 Create the file if it does not exist.\n\
b6ff3a0d3d17 [project @ 2004-09-27 13:50:01 by jwe]
jwe
parents: 4928
diff changeset
398 \n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
399 @item O_NONBLOCK\n\
10791
3140cb7a05a1 Add spellchecker scripts for Octave and run spellcheck of documentation
Rik <octave@nomad.inbox5.com>
parents: 10762
diff changeset
400 Non-blocking mode.\n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
401 \n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
402 @item O_SYNC\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
403 Wait for writes to complete.\n\
2669
c821858188b6 [project @ 1997-02-13 18:25:39 by jwe]
jwe
parents: 2475
diff changeset
404 \n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
405 @item O_ASYNC\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
406 Asynchronous I/O.\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
407 @end vtable\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
408 \n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
409 @item F_SETFL\n\
20172
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
410 Set the file status flags for @var{fid} to the value specified by @var{arg}.\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
411 The only flags that can be changed are @w{@code{O_APPEND}} and\n\
9209
923c7cb7f13f Simplify TeXinfo files by eliminating redundant @iftex followed by @tex construction.
Rik <rdrider0-list@yahoo.com>
parents: 9064
diff changeset
412 @w{@code{O_NONBLOCK}}.\n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
413 @end vtable\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
414 \n\
20172
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
415 If successful, @var{err} is 0 and @var{msg} is an empty string. Otherwise,\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
416 @var{err} is nonzero and @var{msg} contains a system-dependent error\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
417 message.\n\
19109
e90bfaadb489 doc: Increase seealso links between low level C IO functions.
Rik <rik@octave.org>
parents: 18112
diff changeset
418 @seealso{fopen, dup2}\n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
419 @end deftypefn")
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
420 {
20887
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
421 if (args.length () != 3)
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5775
diff changeset
422 print_usage ();
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
423
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
424 octave_stream strm = octave_stream_list::lookup (args(0), "fcntl");
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
425
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
426 int fid = strm.file_number ();
3715
e5ff21d2bac6 [project @ 2000-09-01 05:52:56 by jwe]
jwe
parents: 3531
diff changeset
427
20887
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
428 // FIXME: Do we want to use xint_value and throw a warning message
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
429 // if input validation fails?
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
430 int req = args(1).int_value (true);
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
431 int arg = args(2).int_value (true);
3715
e5ff21d2bac6 [project @ 2000-09-01 05:52:56 by jwe]
jwe
parents: 3531
diff changeset
432
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
433 // FIXME: Need better checking here?
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
434 if (fid < 0)
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
435 error ("fcntl: invalid file id");
2937
9d26524e2869 [project @ 1997-05-06 05:49:53 by jwe]
jwe
parents: 2926
diff changeset
436
20887
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
437 std::string msg;
2669
c821858188b6 [project @ 1997-02-13 18:25:39 by jwe]
jwe
parents: 2475
diff changeset
438
21727
e0da98857c19 rename octave::syscalls namespace to octave::sys
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
439 int status = octave::sys::fcntl (fid, req, arg, msg);
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
440
20887
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
441 return ovl (status, msg);
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
442 }
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
443
10299
c992efc0c2fa use DEFUNX instead of DEFUN for all functions in syscalls.cc
John W. Eaton <jwe@octave.org>
parents: 10259
diff changeset
444 DEFUNX ("fork", Ffork, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
445 "-*- texinfo -*-\n\
20853
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20819
diff changeset
446 @deftypefn {} {[@var{pid}, @var{msg}] =} fork ()\n\
2669
c821858188b6 [project @ 1997-02-13 18:25:39 by jwe]
jwe
parents: 2475
diff changeset
447 Create a copy of the current process.\n\
c821858188b6 [project @ 1997-02-13 18:25:39 by jwe]
jwe
parents: 2475
diff changeset
448 \n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
449 Fork can return one of the following values:\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
450 \n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
451 @table @asis\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
452 @item > 0\n\
20172
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
453 You are in the parent process. The value returned from @code{fork} is the\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
454 process id of the child process. You should probably arrange to wait for\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
455 any child processes to exit.\n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
456 \n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
457 @item 0\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
458 You are in the child process. You can call @code{exec} to start another\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
459 process. If that fails, you should probably call @code{exit}.\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
460 \n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
461 @item < 0\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
462 The call to @code{fork} failed for some reason. You must take evasive\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
463 action. A system dependent error message will be waiting in @var{msg}.\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
464 @end table\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
465 @end deftypefn")
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
466 {
20887
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
467 if (args.length () != 0)
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5775
diff changeset
468 print_usage ();
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
469
21343
980abb267014 Emit error if fork called directly from command line.
Rik <rik@octave.org>
parents: 21301
diff changeset
470 if (symbol_table::at_top_level ())
21604
d7a268e68e69 maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents: 21547
diff changeset
471 error ("fork: cannot be called from command line");
21343
980abb267014 Emit error if fork called directly from command line.
Rik <rik@octave.org>
parents: 21301
diff changeset
472
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
473 std::string msg;
2669
c821858188b6 [project @ 1997-02-13 18:25:39 by jwe]
jwe
parents: 2475
diff changeset
474
21727
e0da98857c19 rename octave::syscalls namespace to octave::sys
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
475 pid_t pid = octave::sys::fork (msg);
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
476
20887
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
477 return ovl (pid, msg);
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
478 }
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
479
10299
c992efc0c2fa use DEFUNX instead of DEFUN for all functions in syscalls.cc
John W. Eaton <jwe@octave.org>
parents: 10259
diff changeset
480 DEFUNX ("getpgrp", Fgetpgrp, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
481 "-*- texinfo -*-\n\
20853
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20819
diff changeset
482 @deftypefn {} {pgid =} getpgrp ()\n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
483 Return the process group id of the current process.\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
484 @end deftypefn")
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
485 {
20887
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
486 if (args.length () != 0)
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5775
diff changeset
487 print_usage ();
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
488
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
489 std::string msg;
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
490
21727
e0da98857c19 rename octave::syscalls namespace to octave::sys
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
491 pid_t pid = octave::sys::getpgrp (msg);
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
492
20887
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
493 return ovl (pid, msg);
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
494 }
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
495
10299
c992efc0c2fa use DEFUNX instead of DEFUN for all functions in syscalls.cc
John W. Eaton <jwe@octave.org>
parents: 10259
diff changeset
496 DEFUNX ("getpid", Fgetpid, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
497 "-*- texinfo -*-\n\
20853
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20819
diff changeset
498 @deftypefn {} {pid =} getpid ()\n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
499 Return the process id of the current process.\n\
20172
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
500 @seealso{getppid}\n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
501 @end deftypefn")
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
502 {
20887
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
503 if (args.length () != 0)
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5775
diff changeset
504 print_usage ();
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
505
21727
e0da98857c19 rename octave::syscalls namespace to octave::sys
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
506 return ovl (octave::sys::getpid ());
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
507 }
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
508
10299
c992efc0c2fa use DEFUNX instead of DEFUN for all functions in syscalls.cc
John W. Eaton <jwe@octave.org>
parents: 10259
diff changeset
509 DEFUNX ("getppid", Fgetppid, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
510 "-*- texinfo -*-\n\
20853
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20819
diff changeset
511 @deftypefn {} {pid =} getppid ()\n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
512 Return the process id of the parent process.\n\
20172
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
513 @seealso{getpid}\n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
514 @end deftypefn")
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
515 {
20887
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
516 if (args.length () != 0)
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5775
diff changeset
517 print_usage ();
2475
1d7925d6bede [project @ 1996-11-07 04:36:00 by jwe]
jwe
parents: 2473
diff changeset
518
21727
e0da98857c19 rename octave::syscalls namespace to octave::sys
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
519 return ovl (octave::sys::getppid ());
2475
1d7925d6bede [project @ 1996-11-07 04:36:00 by jwe]
jwe
parents: 2473
diff changeset
520 }
1d7925d6bede [project @ 1996-11-07 04:36:00 by jwe]
jwe
parents: 2473
diff changeset
521
10299
c992efc0c2fa use DEFUNX instead of DEFUN for all functions in syscalls.cc
John W. Eaton <jwe@octave.org>
parents: 10259
diff changeset
522 DEFUNX ("getegid", Fgetegid, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
523 "-*- texinfo -*-\n\
20853
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20819
diff changeset
524 @deftypefn {} {egid =} getegid ()\n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
525 Return the effective group id of the current process.\n\
20172
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
526 @seealso{getgid}\n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
527 @end deftypefn")
2475
1d7925d6bede [project @ 1996-11-07 04:36:00 by jwe]
jwe
parents: 2473
diff changeset
528 {
20887
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
529 if (args.length () != 0)
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5775
diff changeset
530 print_usage ();
2475
1d7925d6bede [project @ 1996-11-07 04:36:00 by jwe]
jwe
parents: 2473
diff changeset
531
21727
e0da98857c19 rename octave::syscalls namespace to octave::sys
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
532 return ovl (octave::sys::getegid ());
2475
1d7925d6bede [project @ 1996-11-07 04:36:00 by jwe]
jwe
parents: 2473
diff changeset
533 }
1d7925d6bede [project @ 1996-11-07 04:36:00 by jwe]
jwe
parents: 2473
diff changeset
534
10299
c992efc0c2fa use DEFUNX instead of DEFUN for all functions in syscalls.cc
John W. Eaton <jwe@octave.org>
parents: 10259
diff changeset
535 DEFUNX ("getgid", Fgetgid, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
536 "-*- texinfo -*-\n\
20853
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20819
diff changeset
537 @deftypefn {} {gid =} getgid ()\n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
538 Return the real group id of the current process.\n\
20172
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
539 @seealso{getegid}\n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
540 @end deftypefn")
2475
1d7925d6bede [project @ 1996-11-07 04:36:00 by jwe]
jwe
parents: 2473
diff changeset
541 {
20887
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
542 if (args.length () != 0)
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5775
diff changeset
543 print_usage ();
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
544
21727
e0da98857c19 rename octave::syscalls namespace to octave::sys
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
545 return ovl (octave::sys::getgid ());
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
546 }
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
547
10299
c992efc0c2fa use DEFUNX instead of DEFUN for all functions in syscalls.cc
John W. Eaton <jwe@octave.org>
parents: 10259
diff changeset
548 DEFUNX ("geteuid", Fgeteuid, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
549 "-*- texinfo -*-\n\
20853
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20819
diff changeset
550 @deftypefn {} {euid =} geteuid ()\n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
551 Return the effective user id of the current process.\n\
20172
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
552 @seealso{getuid}\n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
553 @end deftypefn")
2472
0c788e9b53b8 [project @ 1996-11-06 04:10:07 by jwe]
jwe
parents: 2457
diff changeset
554 {
20887
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
555 if (args.length () != 0)
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5775
diff changeset
556 print_usage ();
2473
bb0c213e5885 [project @ 1996-11-06 04:34:55 by jwe]
jwe
parents: 2472
diff changeset
557
21727
e0da98857c19 rename octave::syscalls namespace to octave::sys
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
558 return ovl (octave::sys::geteuid ());
2472
0c788e9b53b8 [project @ 1996-11-06 04:10:07 by jwe]
jwe
parents: 2457
diff changeset
559 }
0c788e9b53b8 [project @ 1996-11-06 04:10:07 by jwe]
jwe
parents: 2457
diff changeset
560
10299
c992efc0c2fa use DEFUNX instead of DEFUN for all functions in syscalls.cc
John W. Eaton <jwe@octave.org>
parents: 10259
diff changeset
561 DEFUNX ("getuid", Fgetuid, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
562 "-*- texinfo -*-\n\
20853
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20819
diff changeset
563 @deftypefn {} {uid =} getuid ()\n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
564 Return the real user id of the current process.\n\
20172
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
565 @seealso{geteuid}\n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
566 @end deftypefn")
2472
0c788e9b53b8 [project @ 1996-11-06 04:10:07 by jwe]
jwe
parents: 2457
diff changeset
567 {
20887
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
568 if (args.length () != 0)
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5775
diff changeset
569 print_usage ();
2473
bb0c213e5885 [project @ 1996-11-06 04:34:55 by jwe]
jwe
parents: 2472
diff changeset
570
21727
e0da98857c19 rename octave::syscalls namespace to octave::sys
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
571 return ovl (octave::sys::getuid ());
2472
0c788e9b53b8 [project @ 1996-11-06 04:10:07 by jwe]
jwe
parents: 2457
diff changeset
572 }
0c788e9b53b8 [project @ 1996-11-06 04:10:07 by jwe]
jwe
parents: 2457
diff changeset
573
10299
c992efc0c2fa use DEFUNX instead of DEFUN for all functions in syscalls.cc
John W. Eaton <jwe@octave.org>
parents: 10259
diff changeset
574 DEFUNX ("kill", Fkill, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
575 "-*- texinfo -*-\n\
20853
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20819
diff changeset
576 @deftypefn {} {[@var{err}, @var{msg}] =} kill (@var{pid}, @var{sig})\n\
4294
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4254
diff changeset
577 Send signal @var{sig} to process @var{pid}.\n\
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4254
diff changeset
578 \n\
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4254
diff changeset
579 If @var{pid} is positive, then signal @var{sig} is sent to @var{pid}.\n\
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4254
diff changeset
580 \n\
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4254
diff changeset
581 If @var{pid} is 0, then signal @var{sig} is sent to every process\n\
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4254
diff changeset
582 in the process group of the current process.\n\
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4254
diff changeset
583 \n\
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4254
diff changeset
584 If @var{pid} is -1, then signal @var{sig} is sent to every process\n\
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4254
diff changeset
585 except process 1.\n\
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4254
diff changeset
586 \n\
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4254
diff changeset
587 If @var{pid} is less than -1, then signal @var{sig} is sent to every\n\
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4254
diff changeset
588 process in the process group @var{-pid}.\n\
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4254
diff changeset
589 \n\
4371
c14ec945fabb [project @ 2003-03-26 16:05:59 by jwe]
jwe
parents: 4327
diff changeset
590 If @var{sig} is 0, then no signal is sent, but error checking is still\n\
4294
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4254
diff changeset
591 performed.\n\
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4254
diff changeset
592 \n\
7001
8b0cfeb06365 [project @ 2007-10-10 18:02:59 by jwe]
jwe
parents: 6923
diff changeset
593 Return 0 if successful, otherwise return -1.\n\
4294
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4254
diff changeset
594 @end deftypefn")
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4254
diff changeset
595 {
20856
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
596 if (args.length () != 2)
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5775
diff changeset
597 print_usage ();
4294
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4254
diff changeset
598
20856
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
599 pid_t pid = args(0).int_value (true);
20560
56fee8f84fe7 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
600
20856
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
601 int sig = args(1).int_value (true);
4294
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4254
diff changeset
602
20856
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
603 std::string msg;
4294
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4254
diff changeset
604
21727
e0da98857c19 rename octave::syscalls namespace to octave::sys
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
605 int status = octave::sys::kill (pid, sig, msg);
20856
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
606
20887
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
607 return ovl (status, msg);
4294
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4254
diff changeset
608 }
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4254
diff changeset
609
10299
c992efc0c2fa use DEFUNX instead of DEFUN for all functions in syscalls.cc
John W. Eaton <jwe@octave.org>
parents: 10259
diff changeset
610 DEFUNX ("lstat", Flstat, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
611 "-*- texinfo -*-\n\
20853
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20819
diff changeset
612 @deftypefn {} {@var{info} =} lstat (@var{symlink})\n\
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20819
diff changeset
613 @deftypefnx {} {[@var{info}, @var{err}, @var{msg}] =} lstat (@var{symlink})\n\
12211
11faa69c4eaa Add S_ISBLK and family of functions to documentation.
Rik <octave@nomad.inbox5.com>
parents: 11586
diff changeset
614 Return a structure @var{info} containing information about the symbolic link\n\
17397
0bf2fc8562c9 doc: Update documentation for file and directory functions.
Rik <rik@octave.org>
parents: 17281
diff changeset
615 @var{symlink}.\n\
0bf2fc8562c9 doc: Update documentation for file and directory functions.
Rik <rik@octave.org>
parents: 17281
diff changeset
616 \n\
0bf2fc8562c9 doc: Update documentation for file and directory functions.
Rik <rik@octave.org>
parents: 17281
diff changeset
617 The function outputs are described in the documentation for @code{stat}.\n\
0bf2fc8562c9 doc: Update documentation for file and directory functions.
Rik <rik@octave.org>
parents: 17281
diff changeset
618 @seealso{stat, symlink}\n\
3458
d25bc039237b [project @ 2000-01-19 09:36:14 by jwe]
jwe
parents: 3446
diff changeset
619 @end deftypefn")
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
620 {
20856
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
621 if (args.length () != 1)
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
622 print_usage ();
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
623
20887
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
624 std::string fname = args(0).xstring_value ("lstat: NAME must be a string");
20856
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
625
21736
0504351a45e6 use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
626 octave::sys::file_stat fs (fname, false);
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
627
20887
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
628 return mk_stat_result (fs);
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
629 }
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
630
20200
d9f35ceff9e1 Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents: 20198
diff changeset
631 // FIXME: This routine also exists verbatim in file-io.cc.
d9f35ceff9e1 Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents: 20198
diff changeset
632 // Maybe change to be a general utility routine.
d9f35ceff9e1 Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents: 20198
diff changeset
633 static int
d9f35ceff9e1 Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents: 20198
diff changeset
634 convert (int x, int ibase, int obase)
d9f35ceff9e1 Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents: 20198
diff changeset
635 {
d9f35ceff9e1 Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents: 20198
diff changeset
636 int retval = 0;
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
637
20200
d9f35ceff9e1 Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents: 20198
diff changeset
638 int tmp = x % obase;
d9f35ceff9e1 Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents: 20198
diff changeset
639
d9f35ceff9e1 Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents: 20198
diff changeset
640 if (tmp > ibase - 1)
20428
7ac907da9fba Use error() rather than ::error() unless explicitly required.
Rik <rik@octave.org>
parents: 20232
diff changeset
641 error ("mkfifo: invalid digit");
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
642
21055
5e00ed38a58b maint: Replace if/error/else paradigm with just if/error.
Rik <rik@octave.org>
parents: 20990
diff changeset
643 retval = tmp;
5e00ed38a58b maint: Replace if/error/else paradigm with just if/error.
Rik <rik@octave.org>
parents: 20990
diff changeset
644 int mult = ibase;
5e00ed38a58b maint: Replace if/error/else paradigm with just if/error.
Rik <rik@octave.org>
parents: 20990
diff changeset
645 while ((x = (x - tmp) / obase))
20200
d9f35ceff9e1 Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents: 20198
diff changeset
646 {
21055
5e00ed38a58b maint: Replace if/error/else paradigm with just if/error.
Rik <rik@octave.org>
parents: 20990
diff changeset
647 tmp = x % obase;
5e00ed38a58b maint: Replace if/error/else paradigm with just if/error.
Rik <rik@octave.org>
parents: 20990
diff changeset
648
5e00ed38a58b maint: Replace if/error/else paradigm with just if/error.
Rik <rik@octave.org>
parents: 20990
diff changeset
649 if (tmp > ibase - 1)
5e00ed38a58b maint: Replace if/error/else paradigm with just if/error.
Rik <rik@octave.org>
parents: 20990
diff changeset
650 error ("mkfifo: invalid digit");
5e00ed38a58b maint: Replace if/error/else paradigm with just if/error.
Rik <rik@octave.org>
parents: 20990
diff changeset
651
5e00ed38a58b maint: Replace if/error/else paradigm with just if/error.
Rik <rik@octave.org>
parents: 20990
diff changeset
652 retval += mult * tmp;
5e00ed38a58b maint: Replace if/error/else paradigm with just if/error.
Rik <rik@octave.org>
parents: 20990
diff changeset
653 mult *= ibase;
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
654 }
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
655
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
656 return retval;
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
657 }
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
658
10197
4d433bd2d4dc attempt to avoid trouble with gnulib #defines in a consistent way
John W. Eaton <jwe@octave.org>
parents: 10182
diff changeset
659 DEFUNX ("mkfifo", Fmkfifo, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
660 "-*- texinfo -*-\n\
20853
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20819
diff changeset
661 @deftypefn {} {@var{err} =} mkfifo (@var{name}, @var{mode})\n\
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20819
diff changeset
662 @deftypefnx {} {[@var{err}, @var{msg}] =} mkfifo (@var{name}, @var{mode})\n\
20198
b597bd161a5f doc: Document that mkfifo's mode argument is in decimal (bug #45054).
Rik <rik@octave.org>
parents: 20181
diff changeset
663 Create a FIFO special file named @var{name} with file mode @var{mode}.\n\
b597bd161a5f doc: Document that mkfifo's mode argument is in decimal (bug #45054).
Rik <rik@octave.org>
parents: 20181
diff changeset
664 \n\
20200
d9f35ceff9e1 Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents: 20198
diff changeset
665 @var{mode} is interpreted as an octal number and is subject to umask\n\
d9f35ceff9e1 Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents: 20198
diff changeset
666 processing. The final calculated mode is @code{@var{mode} - @var{umask}}.\n\
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
667 \n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
668 If successful, @var{err} is 0 and @var{msg} is an empty string.\n\
20172
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
669 Otherwise, @var{err} is nonzero and @var{msg} contains a system-dependent\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
670 error message.\n\
20198
b597bd161a5f doc: Document that mkfifo's mode argument is in decimal (bug #45054).
Rik <rik@octave.org>
parents: 20181
diff changeset
671 @seealso{pipe, umask}\n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
672 @end deftypefn")
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
673 {
20887
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
674 if (args.length () != 2)
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5775
diff changeset
675 print_usage ();
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
676
20856
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
677 std::string name = args(0).xstring_value ("mkfifo: FILE must be a string");
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
678
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
679 int octal_mode = args(1).xint_value ("mkfifo: MODE must be an integer");
4254
df5f2e433a11 [project @ 2002-12-31 19:43:07 by jwe]
jwe
parents: 4233
diff changeset
680
20856
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
681 if (octal_mode < 0)
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
682 error ("mkfifo: MODE must be a positive integer value");
20887
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
683
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
684 int mode = convert (octal_mode, 8, 10);
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
685
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
686 std::string msg;
20856
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
687
21733
cb0fdd941d84 use namespace for system file_ops class
John W. Eaton <jwe@octave.org>
parents: 21732
diff changeset
688 int status = octave::sys::mkfifo (name, mode, msg);
20856
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
689
20887
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
690 return ovl (status, msg);
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
691 }
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
692
20200
d9f35ceff9e1 Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents: 20198
diff changeset
693 /*
d9f35ceff9e1 Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents: 20198
diff changeset
694
d9f35ceff9e1 Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents: 20198
diff changeset
695 ## Test input validation
d9f35ceff9e1 Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents: 20198
diff changeset
696 %!error mkfifo ()
d9f35ceff9e1 Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents: 20198
diff changeset
697 %!error mkfifo ("abc")
d9f35ceff9e1 Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents: 20198
diff changeset
698 %!error mkfifo ("abc", 777, 123)
d9f35ceff9e1 Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents: 20198
diff changeset
699 %!error <FILE must be a string> mkfifo (123, 456)
d9f35ceff9e1 Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents: 20198
diff changeset
700 ## FIXME: These tests should work, but lasterr is not being set correctly.
d9f35ceff9e1 Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents: 20198
diff changeset
701 #%!error <MODE must be an integer> mkfifo ("abc", {456})
d9f35ceff9e1 Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents: 20198
diff changeset
702 #%!error <MODE must be a positive integer value> mkfifo ("abc", -1)
d9f35ceff9e1 Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents: 20198
diff changeset
703
d9f35ceff9e1 Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents: 20198
diff changeset
704 */
d9f35ceff9e1 Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents: 20198
diff changeset
705
10299
c992efc0c2fa use DEFUNX instead of DEFUN for all functions in syscalls.cc
John W. Eaton <jwe@octave.org>
parents: 10259
diff changeset
706 DEFUNX ("pipe", Fpipe, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
707 "-*- texinfo -*-\n\
20853
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20819
diff changeset
708 @deftypefn {} {[@var{read_fd}, @var{write_fd}, @var{err}, @var{msg}] =} pipe ()\n\
20172
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
709 Create a pipe and return the reading and writing ends of the pipe into\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
710 @var{read_fd} and @var{write_fd} respectively.\n\
2669
c821858188b6 [project @ 1997-02-13 18:25:39 by jwe]
jwe
parents: 2475
diff changeset
711 \n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
712 If successful, @var{err} is 0 and @var{msg} is an empty string.\n\
20172
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
713 Otherwise, @var{err} is nonzero and @var{msg} contains a system-dependent\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
714 error message.\n\
17397
0bf2fc8562c9 doc: Update documentation for file and directory functions.
Rik <rik@octave.org>
parents: 17281
diff changeset
715 @seealso{mkfifo}\n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
716 @end deftypefn")
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
717 {
20887
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
718 if (args.length () != 0)
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5775
diff changeset
719 print_usage ();
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
720
20856
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
721 int fid[2];
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
722 std::string msg;
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
723
21727
e0da98857c19 rename octave::syscalls namespace to octave::sys
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
724 int status = octave::sys::pipe (fid, msg);
2669
c821858188b6 [project @ 1997-02-13 18:25:39 by jwe]
jwe
parents: 2475
diff changeset
725
20856
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
726 if (status < 0)
20887
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
727 return ovl (-1, -1, -1, msg);
20856
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
728 else
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
729 {
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
730 FILE *ifile = fdopen (fid[0], "r");
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
731 FILE *ofile = fdopen (fid[1], "w");
4327
c29c382a5b4b [project @ 2003-02-16 03:24:26 by jwe]
jwe
parents: 4294
diff changeset
732
20856
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
733 octave_stream is = octave_stdiostream::create ("pipe-in", ifile,
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
734 std::ios::in);
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
735
20856
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
736 octave_stream os = octave_stdiostream::create ("pipe-out", ofile,
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
737 std::ios::out);
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
738
20887
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
739 return ovl (octave_stream_list::insert (is),
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
740 octave_stream_list::insert (os),
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
741 status,
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
742 msg);
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
743 }
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
744 }
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
745
10299
c992efc0c2fa use DEFUNX instead of DEFUN for all functions in syscalls.cc
John W. Eaton <jwe@octave.org>
parents: 10259
diff changeset
746 DEFUNX ("stat", Fstat, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
747 "-*- texinfo -*-\n\
20853
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20819
diff changeset
748 @deftypefn {} {[@var{info}, @var{err}, @var{msg}] =} stat (@var{file})\n\
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20819
diff changeset
749 @deftypefnx {} {[@var{info}, @var{err}, @var{msg}] =} stat (@var{fid})\n\
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20819
diff changeset
750 @deftypefnx {} {[@var{info}, @var{err}, @var{msg}] =} lstat (@var{file})\n\
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20819
diff changeset
751 @deftypefnx {} {[@var{info}, @var{err}, @var{msg}] =} lstat (@var{fid})\n\
12211
11faa69c4eaa Add S_ISBLK and family of functions to documentation.
Rik <octave@nomad.inbox5.com>
parents: 11586
diff changeset
752 Return a structure @var{info} containing the following information about\n\
11417
1a7b41db5432 Add additional calling form using file descriptor (fid) to docstring for stat.
Rik <octave@nomad.inbox5.com>
parents: 11152
diff changeset
753 @var{file} or file identifier @var{fid}.\n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
754 \n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
755 @table @code\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
756 @item dev\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
757 ID of device containing a directory entry for this file.\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
758 \n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
759 @item ino\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
760 File number of the file.\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
761 \n\
5476
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
762 @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
763 File mode, as an integer. Use the functions @w{@code{S_ISREG}},\n\
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17236
diff changeset
764 @w{@code{S_ISDIR}}, @w{@code{S_ISCHR}}, @w{@code{S_ISBLK}},\n\
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17236
diff changeset
765 @w{@code{S_ISFIFO}}, @w{@code{S_ISLNK}}, or @w{@code{S_ISSOCK}} to extract\n\
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17236
diff changeset
766 information from this value.\n\
5476
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
767 \n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
768 @item modestr\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
769 File mode, as a string of ten letters or dashes as would be returned by\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
770 @kbd{ls -l}.\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
771 \n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
772 @item nlink\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
773 Number of links.\n\
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
774 \n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
775 @item uid\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
776 User ID of file's owner.\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
777 \n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
778 @item gid\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
779 Group ID of file's group.\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
780 \n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
781 @item rdev\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
782 ID of device for block or character special files.\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
783 \n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
784 @item size\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
785 Size in bytes.\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
786 \n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
787 @item atime\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
788 Time of last access in the same form as time values returned from\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
789 @code{time}. @xref{Timing Utilities}.\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
790 \n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
791 @item mtime\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
792 Time of last modification in the same form as time values returned from\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
793 @code{time}. @xref{Timing Utilities}.\n\
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
794 \n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
795 @item ctime\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
796 Time of last file status change in the same form as time values\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
797 returned from @code{time}. @xref{Timing Utilities}.\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
798 \n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
799 @item blksize\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
800 Size of blocks in the file.\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
801 \n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
802 @item blocks\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
803 Number of blocks allocated for file.\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
804 @end table\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
805 \n\
20172
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
806 If the call is successful @var{err} is 0 and @var{msg} is an empty string.\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
807 If the file does not exist, or some other error occurs, @var{info} is an\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
808 empty matrix, @var{err} is @minus{}1, and @var{msg} contains the\n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
809 corresponding system error message.\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
810 \n\
20172
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
811 If @var{file} is a symbolic link, @code{stat} will return information about\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
812 the actual file that is referenced by the link. Use @code{lstat} if you\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
813 want information about the symbolic link itself.\n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
814 \n\
10840
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10791
diff changeset
815 For example:\n\
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
816 \n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
817 @example\n\
15065
f7215831fe78 doc: be consistent on var name on stat help text
Carnë Draug <carandraug+dev@gmail.com>
parents: 14861
diff changeset
818 [info, err, msg] = stat (\"/vmlinuz\")\n\
f7215831fe78 doc: be consistent on var name on stat help text
Carnë Draug <carandraug+dev@gmail.com>
parents: 14861
diff changeset
819 @result{} info =\n\
14360
97883071e8e4 doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents: 14171
diff changeset
820 @{\n\
97883071e8e4 doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents: 14171
diff changeset
821 atime = 855399756\n\
97883071e8e4 doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents: 14171
diff changeset
822 rdev = 0\n\
97883071e8e4 doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents: 14171
diff changeset
823 ctime = 847219094\n\
97883071e8e4 doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents: 14171
diff changeset
824 uid = 0\n\
97883071e8e4 doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents: 14171
diff changeset
825 size = 389218\n\
97883071e8e4 doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents: 14171
diff changeset
826 blksize = 4096\n\
97883071e8e4 doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents: 14171
diff changeset
827 mtime = 847219094\n\
97883071e8e4 doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents: 14171
diff changeset
828 gid = 6\n\
97883071e8e4 doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents: 14171
diff changeset
829 nlink = 1\n\
97883071e8e4 doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents: 14171
diff changeset
830 blocks = 768\n\
97883071e8e4 doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents: 14171
diff changeset
831 mode = -rw-r--r--\n\
97883071e8e4 doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents: 14171
diff changeset
832 modestr = -rw-r--r--\n\
97883071e8e4 doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents: 14171
diff changeset
833 ino = 9316\n\
97883071e8e4 doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents: 14171
diff changeset
834 dev = 2049\n\
97883071e8e4 doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents: 14171
diff changeset
835 @}\n\
97883071e8e4 doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents: 14171
diff changeset
836 @result{} err = 0\n\
97883071e8e4 doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents: 14171
diff changeset
837 @result{} msg =\n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
838 @end example\n\
17397
0bf2fc8562c9 doc: Update documentation for file and directory functions.
Rik <rik@octave.org>
parents: 17281
diff changeset
839 @seealso{lstat, ls, dir}\n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
840 @end deftypefn")
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
841 {
20856
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
842 if (args.length () != 1)
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
843 print_usage ();
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
844
2262
1300df4a33d6 [project @ 1996-05-23 06:49:32 by jwe]
jwe
parents: 2086
diff changeset
845 octave_value_list retval;
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
846
20887
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
847 if (args(0).is_scalar_type ())
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
848 {
20887
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
849 int fid = octave_stream_list::get_file_number (args(0));
10336
1603dfe72933 obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
850
21737
ab6c639f0678 finish previous changeset (0504351a45e6).
John W. Eaton <jwe@octave.org>
parents: 21736
diff changeset
851 octave::sys::file_fstat fs (fid);
10336
1603dfe72933 obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
852
20887
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
853 retval = mk_stat_result (fs);
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
854 }
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
855 else
20887
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
856 {
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
857 std::string fname = args(0).xstring_value ("stat: NAME must be a string");
10336
1603dfe72933 obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
858
21736
0504351a45e6 use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
859 octave::sys::file_stat fs (fname);
10336
1603dfe72933 obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
860
20887
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
861 retval = mk_stat_result (fs);
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
862 }
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
863
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
864 return retval;
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
865 }
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
866
5476
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
867 DEFUNX ("S_ISREG", FS_ISREG, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
868 "-*- texinfo -*-\n\
20853
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20819
diff changeset
869 @deftypefn {} {} S_ISREG (@var{mode})\n\
17397
0bf2fc8562c9 doc: Update documentation for file and directory functions.
Rik <rik@octave.org>
parents: 17281
diff changeset
870 Return true if @var{mode} corresponds to a regular file.\n\
0bf2fc8562c9 doc: Update documentation for file and directory functions.
Rik <rik@octave.org>
parents: 17281
diff changeset
871 \n\
21547
ad0599a0acc6 doc: Wrap C++ docstrings to 79 characters + newline (80 total).
Rik <rik@octave.org>
parents: 21343
diff changeset
872 The value of @var{mode} is assumed to be returned from a call to\n\
ad0599a0acc6 doc: Wrap C++ docstrings to 79 characters + newline (80 total).
Rik <rik@octave.org>
parents: 21343
diff changeset
873 @code{stat}.\n\
5476
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
874 @seealso{stat, lstat}\n\
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
875 @end deftypefn")
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
876 {
20856
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
877 if (args.length () != 1)
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5775
diff changeset
878 print_usage ();
5476
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
879
20856
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
880 double mode = args(0).xdouble_value ("S_ISREG: invalid MODE value");
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
881
21736
0504351a45e6 use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
882 return ovl (octave::sys::file_stat::is_reg (static_cast<mode_t> (mode)));
5476
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
883 }
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
884
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
885 DEFUNX ("S_ISDIR", FS_ISDIR, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
886 "-*- texinfo -*-\n\
20853
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20819
diff changeset
887 @deftypefn {} {} S_ISDIR (@var{mode})\n\
17397
0bf2fc8562c9 doc: Update documentation for file and directory functions.
Rik <rik@octave.org>
parents: 17281
diff changeset
888 Return true if @var{mode} corresponds to a directory.\n\
0bf2fc8562c9 doc: Update documentation for file and directory functions.
Rik <rik@octave.org>
parents: 17281
diff changeset
889 \n\
21547
ad0599a0acc6 doc: Wrap C++ docstrings to 79 characters + newline (80 total).
Rik <rik@octave.org>
parents: 21343
diff changeset
890 The value of @var{mode} is assumed to be returned from a call to\n\
ad0599a0acc6 doc: Wrap C++ docstrings to 79 characters + newline (80 total).
Rik <rik@octave.org>
parents: 21343
diff changeset
891 @code{stat}.\n\
5476
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
892 @seealso{stat, lstat}\n\
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
893 @end deftypefn")
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
894 {
20856
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
895 if (args.length () != 1)
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5775
diff changeset
896 print_usage ();
5476
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
897
20856
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
898 double mode = args(0).xdouble_value ("S_ISDIR: invalid MODE value");
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
899
21736
0504351a45e6 use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
900 return ovl (octave::sys::file_stat::is_dir (static_cast<mode_t> (mode)));
5476
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
901 }
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
902
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
903 DEFUNX ("S_ISCHR", FS_ISCHR, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
904 "-*- texinfo -*-\n\
20853
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20819
diff changeset
905 @deftypefn {} {} S_ISCHR (@var{mode})\n\
17397
0bf2fc8562c9 doc: Update documentation for file and directory functions.
Rik <rik@octave.org>
parents: 17281
diff changeset
906 Return true if @var{mode} corresponds to a character device.\n\
0bf2fc8562c9 doc: Update documentation for file and directory functions.
Rik <rik@octave.org>
parents: 17281
diff changeset
907 \n\
21547
ad0599a0acc6 doc: Wrap C++ docstrings to 79 characters + newline (80 total).
Rik <rik@octave.org>
parents: 21343
diff changeset
908 The value of @var{mode} is assumed to be returned from a call to\n\
ad0599a0acc6 doc: Wrap C++ docstrings to 79 characters + newline (80 total).
Rik <rik@octave.org>
parents: 21343
diff changeset
909 @code{stat}.\n\
5476
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
910 @seealso{stat, lstat}\n\
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
911 @end deftypefn")
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
912 {
20856
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
913 if (args.length () != 1)
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5775
diff changeset
914 print_usage ();
5476
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
915
20856
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
916 double mode = args(0).xdouble_value ("S_ISCHR: invalid MODE value");
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
917
21736
0504351a45e6 use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
918 return ovl (octave::sys::file_stat::is_chr (static_cast<mode_t> (mode)));
5476
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
919 }
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
920
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
921 DEFUNX ("S_ISBLK", FS_ISBLK, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
922 "-*- texinfo -*-\n\
20853
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20819
diff changeset
923 @deftypefn {} {} S_ISBLK (@var{mode})\n\
17397
0bf2fc8562c9 doc: Update documentation for file and directory functions.
Rik <rik@octave.org>
parents: 17281
diff changeset
924 Return true if @var{mode} corresponds to a block device.\n\
0bf2fc8562c9 doc: Update documentation for file and directory functions.
Rik <rik@octave.org>
parents: 17281
diff changeset
925 \n\
21547
ad0599a0acc6 doc: Wrap C++ docstrings to 79 characters + newline (80 total).
Rik <rik@octave.org>
parents: 21343
diff changeset
926 The value of @var{mode} is assumed to be returned from a call to\n\
ad0599a0acc6 doc: Wrap C++ docstrings to 79 characters + newline (80 total).
Rik <rik@octave.org>
parents: 21343
diff changeset
927 @code{stat}.\n\
5476
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
928 @seealso{stat, lstat}\n\
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
929 @end deftypefn")
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
930 {
20856
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
931 if (args.length () != 1)
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5775
diff changeset
932 print_usage ();
5476
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
933
20856
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
934 double mode = args(0).xdouble_value ("S_ISBLK: invalid MODE value");
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
935
21736
0504351a45e6 use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
936 return ovl (octave::sys::file_stat::is_blk (static_cast<mode_t> (mode)));
5476
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
937 }
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
938
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
939 DEFUNX ("S_ISFIFO", FS_ISFIFO, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
940 "-*- texinfo -*-\n\
20853
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20819
diff changeset
941 @deftypefn {} {} S_ISFIFO (@var{mode})\n\
17397
0bf2fc8562c9 doc: Update documentation for file and directory functions.
Rik <rik@octave.org>
parents: 17281
diff changeset
942 Return true if @var{mode} corresponds to a fifo.\n\
0bf2fc8562c9 doc: Update documentation for file and directory functions.
Rik <rik@octave.org>
parents: 17281
diff changeset
943 \n\
21547
ad0599a0acc6 doc: Wrap C++ docstrings to 79 characters + newline (80 total).
Rik <rik@octave.org>
parents: 21343
diff changeset
944 The value of @var{mode} is assumed to be returned from a call to\n\
ad0599a0acc6 doc: Wrap C++ docstrings to 79 characters + newline (80 total).
Rik <rik@octave.org>
parents: 21343
diff changeset
945 @code{stat}.\n\
5476
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
946 @seealso{stat, lstat}\n\
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
947 @end deftypefn")
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
948 {
20856
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
949 if (args.length () != 1)
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5775
diff changeset
950 print_usage ();
5476
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
951
20856
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
952 double mode = args(0).xdouble_value ("S_ISFIFO: invalid MODE value");
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
953
21736
0504351a45e6 use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
954 return ovl (octave::sys::file_stat::is_fifo (static_cast<mode_t> (mode)));
5476
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
955 }
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
956
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
957 DEFUNX ("S_ISLNK", FS_ISLNK, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
958 "-*- texinfo -*-\n\
20853
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20819
diff changeset
959 @deftypefn {} {} S_ISLNK (@var{mode})\n\
17397
0bf2fc8562c9 doc: Update documentation for file and directory functions.
Rik <rik@octave.org>
parents: 17281
diff changeset
960 Return true if @var{mode} corresponds to a symbolic link.\n\
0bf2fc8562c9 doc: Update documentation for file and directory functions.
Rik <rik@octave.org>
parents: 17281
diff changeset
961 \n\
21547
ad0599a0acc6 doc: Wrap C++ docstrings to 79 characters + newline (80 total).
Rik <rik@octave.org>
parents: 21343
diff changeset
962 The value of @var{mode} is assumed to be returned from a call to\n\
ad0599a0acc6 doc: Wrap C++ docstrings to 79 characters + newline (80 total).
Rik <rik@octave.org>
parents: 21343
diff changeset
963 @code{stat}.\n\
5476
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
964 @seealso{stat, lstat}\n\
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
965 @end deftypefn")
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
966 {
20856
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
967 if (args.length () != 1)
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5775
diff changeset
968 print_usage ();
5476
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
969
20856
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
970 double mode = args(0).xdouble_value ("S_ISLNK: invalid MODE value");
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
971
21736
0504351a45e6 use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
972 return ovl (octave::sys::file_stat::is_lnk (static_cast<mode_t> (mode)));
5476
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
973 }
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
974
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
975 DEFUNX ("S_ISSOCK", FS_ISSOCK, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
976 "-*- texinfo -*-\n\
20853
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20819
diff changeset
977 @deftypefn {} {} S_ISSOCK (@var{mode})\n\
17397
0bf2fc8562c9 doc: Update documentation for file and directory functions.
Rik <rik@octave.org>
parents: 17281
diff changeset
978 Return true if @var{mode} corresponds to a socket.\n\
0bf2fc8562c9 doc: Update documentation for file and directory functions.
Rik <rik@octave.org>
parents: 17281
diff changeset
979 \n\
21547
ad0599a0acc6 doc: Wrap C++ docstrings to 79 characters + newline (80 total).
Rik <rik@octave.org>
parents: 21343
diff changeset
980 The value of @var{mode} is assumed to be returned from a call to\n\
ad0599a0acc6 doc: Wrap C++ docstrings to 79 characters + newline (80 total).
Rik <rik@octave.org>
parents: 21343
diff changeset
981 @code{stat}.\n\
5476
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
982 @seealso{stat, lstat}\n\
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
983 @end deftypefn")
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
984 {
20856
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
985 if (args.length () != 1)
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5775
diff changeset
986 print_usage ();
5476
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
987
20856
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
988 double mode = args(0).xdouble_value ("S_ISSOCK: invalid MODE value");
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
989
21736
0504351a45e6 use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents: 21733
diff changeset
990 return ovl (octave::sys::file_stat::is_sock (static_cast<mode_t> (mode)));
5476
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
991 }
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
992
11006
aca961a3f387 provide gethostname function
John W. Eaton <jwe@octave.org>
parents: 10840
diff changeset
993 DEFUN (gethostname, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
994 "-*- texinfo -*-\n\
20853
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20819
diff changeset
995 @deftypefn {} {} gethostname ()\n\
12514
e5e66c389597 Add gethostname to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12483
diff changeset
996 Return the hostname of the system where Octave is running.\n\
11006
aca961a3f387 provide gethostname function
John W. Eaton <jwe@octave.org>
parents: 10840
diff changeset
997 @end deftypefn")
aca961a3f387 provide gethostname function
John W. Eaton <jwe@octave.org>
parents: 10840
diff changeset
998 {
20856
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
999 if (args.length () != 0)
11006
aca961a3f387 provide gethostname function
John W. Eaton <jwe@octave.org>
parents: 10840
diff changeset
1000 print_usage ();
aca961a3f387 provide gethostname function
John W. Eaton <jwe@octave.org>
parents: 10840
diff changeset
1001
21732
6a1eded90355 use namespace for system env class
John W. Eaton <jwe@octave.org>
parents: 21731
diff changeset
1002 return ovl (octave::sys::env::get_host_name ());
11006
aca961a3f387 provide gethostname function
John W. Eaton <jwe@octave.org>
parents: 10840
diff changeset
1003 }
aca961a3f387 provide gethostname function
John W. Eaton <jwe@octave.org>
parents: 10840
diff changeset
1004
5547
8b0b36c2dc0c [project @ 2005-11-29 17:41:33 by jwe]
jwe
parents: 5476
diff changeset
1005 DEFUN (uname, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1006 "-*- texinfo -*-\n\
20853
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20819
diff changeset
1007 @deftypefn {} {[@var{uts}, @var{err}, @var{msg}] =} uname ()\n\
20172
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
1008 Return system information in the structure.\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
1009 \n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
1010 For example:\n\
5547
8b0b36c2dc0c [project @ 2005-11-29 17:41:33 by jwe]
jwe
parents: 5476
diff changeset
1011 \n\
8b0b36c2dc0c [project @ 2005-11-29 17:41:33 by jwe]
jwe
parents: 5476
diff changeset
1012 @example\n\
8b0b36c2dc0c [project @ 2005-11-29 17:41:33 by jwe]
jwe
parents: 5476
diff changeset
1013 @group\n\
8b0b36c2dc0c [project @ 2005-11-29 17:41:33 by jwe]
jwe
parents: 5476
diff changeset
1014 uname ()\n\
14360
97883071e8e4 doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents: 14171
diff changeset
1015 @result{} @{\n\
97883071e8e4 doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents: 14171
diff changeset
1016 sysname = x86_64\n\
97883071e8e4 doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents: 14171
diff changeset
1017 nodename = segfault\n\
97883071e8e4 doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents: 14171
diff changeset
1018 release = 2.6.15-1-amd64-k8-smp\n\
97883071e8e4 doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents: 14171
diff changeset
1019 version = Linux\n\
97883071e8e4 doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents: 14171
diff changeset
1020 machine = #2 SMP Thu Feb 23 04:57:49 UTC 2006\n\
97883071e8e4 doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents: 14171
diff changeset
1021 @}\n\
5547
8b0b36c2dc0c [project @ 2005-11-29 17:41:33 by jwe]
jwe
parents: 5476
diff changeset
1022 @end group\n\
8b0b36c2dc0c [project @ 2005-11-29 17:41:33 by jwe]
jwe
parents: 5476
diff changeset
1023 @end example\n\
8b0b36c2dc0c [project @ 2005-11-29 17:41:33 by jwe]
jwe
parents: 5476
diff changeset
1024 \n\
8b0b36c2dc0c [project @ 2005-11-29 17:41:33 by jwe]
jwe
parents: 5476
diff changeset
1025 If successful, @var{err} is 0 and @var{msg} is an empty string.\n\
8b0b36c2dc0c [project @ 2005-11-29 17:41:33 by jwe]
jwe
parents: 5476
diff changeset
1026 Otherwise, @var{err} is nonzero and @var{msg} contains a\n\
8b0b36c2dc0c [project @ 2005-11-29 17:41:33 by jwe]
jwe
parents: 5476
diff changeset
1027 system-dependent error message.\n\
8b0b36c2dc0c [project @ 2005-11-29 17:41:33 by jwe]
jwe
parents: 5476
diff changeset
1028 @end deftypefn")
8b0b36c2dc0c [project @ 2005-11-29 17:41:33 by jwe]
jwe
parents: 5476
diff changeset
1029 {
20856
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1030 if (args.length () != 0)
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5775
diff changeset
1031 print_usage ();
5547
8b0b36c2dc0c [project @ 2005-11-29 17:41:33 by jwe]
jwe
parents: 5476
diff changeset
1032
21731
3dfec4c1eb8b use namespace for system uname class
John W. Eaton <jwe@octave.org>
parents: 21727
diff changeset
1033 octave::sys::uname sysinfo;
20856
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1034
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1035 octave_scalar_map m;
5547
8b0b36c2dc0c [project @ 2005-11-29 17:41:33 by jwe]
jwe
parents: 5476
diff changeset
1036
20856
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1037 m.assign ("sysname", sysinfo.sysname ());
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1038 m.assign ("nodename", sysinfo.nodename ());
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1039 m.assign ("release", sysinfo.release ());
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1040 m.assign ("version", sysinfo.version ());
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1041 m.assign ("machine", sysinfo.machine ());
5547
8b0b36c2dc0c [project @ 2005-11-29 17:41:33 by jwe]
jwe
parents: 5476
diff changeset
1042
20887
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
1043 return ovl (m, sysinfo.error (), sysinfo.message ());
5547
8b0b36c2dc0c [project @ 2005-11-29 17:41:33 by jwe]
jwe
parents: 5476
diff changeset
1044 }
8b0b36c2dc0c [project @ 2005-11-29 17:41:33 by jwe]
jwe
parents: 5476
diff changeset
1045
10197
4d433bd2d4dc attempt to avoid trouble with gnulib #defines in a consistent way
John W. Eaton <jwe@octave.org>
parents: 10182
diff changeset
1046 DEFUNX ("unlink", Funlink, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1047 "-*- texinfo -*-\n\
20853
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20819
diff changeset
1048 @deftypefn {} {[@var{err}, @var{msg}] =} unlink (@var{file})\n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
1049 Delete the file named @var{file}.\n\
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1050 \n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
1051 If successful, @var{err} is 0 and @var{msg} is an empty string.\n\
20172
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
1052 Otherwise, @var{err} is nonzero and @var{msg} contains a system-dependent\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
1053 error message.\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
1054 @seealso{delete, rmdir}\n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
1055 @end deftypefn")
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1056 {
20887
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
1057 if (args.length () != 1)
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5775
diff changeset
1058 print_usage ();
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1059
20856
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1060 std::string name = args(0).xstring_value ("unlink: FILE must be a string");
2669
c821858188b6 [project @ 1997-02-13 18:25:39 by jwe]
jwe
parents: 2475
diff changeset
1061
20856
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1062 std::string msg;
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1063
21733
cb0fdd941d84 use namespace for system file_ops class
John W. Eaton <jwe@octave.org>
parents: 21732
diff changeset
1064 int status = octave::sys::unlink (name, msg);
2669
c821858188b6 [project @ 1997-02-13 18:25:39 by jwe]
jwe
parents: 2475
diff changeset
1065
20887
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
1066 return ovl (status, msg);
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1067 }
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1068
10299
c992efc0c2fa use DEFUNX instead of DEFUN for all functions in syscalls.cc
John W. Eaton <jwe@octave.org>
parents: 10259
diff changeset
1069 DEFUNX ("waitpid", Fwaitpid, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1070 "-*- texinfo -*-\n\
20853
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20819
diff changeset
1071 @deftypefn {} {[@var{pid}, @var{status}, @var{msg}] =} waitpid (@var{pid}, @var{options})\n\
20172
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
1072 Wait for process @var{pid} to terminate.\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
1073 \n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
1074 The @var{pid} argument can be:\n\
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1075 \n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
1076 @table @asis\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
1077 @item @minus{}1\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
1078 Wait for any child process.\n\
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1079 \n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
1080 @item 0\n\
20172
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
1081 Wait for any child process whose process group ID is equal to that of the\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
1082 Octave interpreter process.\n\
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1083 \n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
1084 @item > 0\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
1085 Wait for termination of the child process with ID @var{pid}.\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
1086 @end table\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
1087 \n\
20172
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
1088 The @var{options} argument can be a bitwise OR of zero or more of the\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
1089 following constants:\n\
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1090 \n\
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1091 @table @code\n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
1092 @item 0\n\
20172
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
1093 Wait until signal is received or a child process exits (this is the default\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
1094 if the @var{options} argument is missing).\n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
1095 \n\
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1096 @item WNOHANG\n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
1097 Do not hang if status is not immediately available.\n\
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1098 \n\
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1099 @item WUNTRACED\n\
20172
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
1100 Report the status of any child processes that are stopped, and whose status\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
1101 has not yet been reported since they stopped.\n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
1102 \n\
8286
6f2d95255911 fix @seealso references to point to existing anchors
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 7924
diff changeset
1103 @item WCONTINUE\n\
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1104 Return if a stopped child has been resumed by delivery of @code{SIGCONT}.\n\
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1105 This value may not be meaningful on all systems.\n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
1106 @end table\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
1107 \n\
20172
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
1108 If the returned value of @var{pid} is greater than 0, it is the process ID\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
1109 of the child process that exited. If an error occurs, @var{pid} will be\n\
20181
aa36fb998a4d maint: Remove unnecessary whitespace at end of lines.
Rik <rik@octave.org>
parents: 20172
diff changeset
1110 less than zero and @var{msg} will contain a system-dependent error message.\n\
20172
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
1111 The value of @var{status} contains additional system-dependent information\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
1112 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
1113 @seealso{WCONTINUE, WCOREDUMP, WEXITSTATUS, WIFCONTINUED, WIFSIGNALED, WIFSTOPPED, WNOHANG, WSTOPSIG, WTERMSIG, WUNTRACED}\n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
1114 @end deftypefn")
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1115 {
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1116 int nargin = args.length ();
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1117
20856
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1118 if (nargin != 1 && nargin != 2)
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5775
diff changeset
1119 print_usage ();
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1120
20856
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1121 pid_t pid = args(0).xint_value ("waitpid: OPTIONS must be an integer");
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
1122
20856
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1123 int options = 0;
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1124
20887
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
1125 if (nargin == 2)
20856
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1126 options = args(1).xint_value ("waitpid: PID must be an integer value");
2669
c821858188b6 [project @ 1997-02-13 18:25:39 by jwe]
jwe
parents: 2475
diff changeset
1127
20856
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1128 std::string msg;
20887
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
1129 int status;
20856
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1130
21727
e0da98857c19 rename octave::syscalls namespace to octave::sys
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
1131 pid_t result = octave::sys::waitpid (pid, &status, options, msg);
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1132
20887
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
1133 return ovl (result, status, msg);
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1134 }
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1135
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1136 DEFUNX ("WIFEXITED", FWIFEXITED, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1137 "-*- texinfo -*-\n\
20853
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20819
diff changeset
1138 @deftypefn {} {} WIFEXITED (@var{status})\n\
20172
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
1139 Given @var{status} from a call to @code{waitpid}, return\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
1140 true if the child terminated normally.\n\
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1141 @seealso{waitpid, WEXITSTATUS, WIFSIGNALED, WTERMSIG, WCOREDUMP, WIFSTOPPED, WSTOPSIG, WIFCONTINUED}\n\
5646
2b20d1707f29 [project @ 2006-03-06 22:38:32 by jwe]
jwe
parents: 5547
diff changeset
1142 @end deftypefn")
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1143 {
20856
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1144 if (args.length () != 1)
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1145 print_usage ();
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1146
20856
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1147 int status = args(0).xint_value ("WIFEXITED: STATUS must be an integer");
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1148
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20923
diff changeset
1149 return ovl (octave_wait::ifexited (status));
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1150 }
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1151
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1152 DEFUNX ("WEXITSTATUS", FWEXITSTATUS, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1153 "-*- texinfo -*-\n\
20853
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20819
diff changeset
1154 @deftypefn {} {} WEXITSTATUS (@var{status})\n\
20172
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
1155 Given @var{status} from a call to @code{waitpid}, return\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
1156 the exit status of the child.\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
1157 \n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
1158 This function should only be employed if @code{WIFEXITED} returned true.\n\
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1159 @seealso{waitpid, WIFEXITED, WIFSIGNALED, WTERMSIG, WCOREDUMP, WIFSTOPPED, WSTOPSIG, WIFCONTINUED}\n\
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1160 @end deftypefn")
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1161 {
20887
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
1162 if (args.length () != 1)
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
1163 print_usage ();
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1164
20887
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
1165 int status = args(0).xint_value ("WEXITSTATUS: STATUS must be an integer");
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1166
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20923
diff changeset
1167 return ovl (octave_wait::exitstatus (status));
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1168 }
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1169
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1170 DEFUNX ("WIFSIGNALED", FWIFSIGNALED, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1171 "-*- texinfo -*-\n\
20853
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20819
diff changeset
1172 @deftypefn {} {} WIFSIGNALED (@var{status})\n\
20172
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
1173 Given @var{status} from a call to @code{waitpid}, return\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
1174 true if the child process was terminated by a signal.\n\
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1175 @seealso{waitpid, WIFEXITED, WEXITSTATUS, WTERMSIG, WCOREDUMP, WIFSTOPPED, WSTOPSIG, WIFCONTINUED}\n\
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1176 @end deftypefn")
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1177 {
20856
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1178 if (args.length () != 1)
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1179 print_usage ();
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1180
20856
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1181 int status = args(0).xint_value ("WIFSIGNALED: STATUS must be an integer");
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1182
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20923
diff changeset
1183 return ovl (octave_wait::ifsignaled (status));
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1184 }
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1185
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1186 DEFUNX ("WTERMSIG", FWTERMSIG, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1187 "-*- texinfo -*-\n\
20853
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20819
diff changeset
1188 @deftypefn {} {} WTERMSIG (@var{status})\n\
20172
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
1189 Given @var{status} from a call to @code{waitpid}, return\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
1190 the number of the signal that caused the child process to terminate.\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
1191 \n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
1192 This function should only be employed if @code{WIFSIGNALED} returned true.\n\
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1193 @seealso{waitpid, WIFEXITED, WEXITSTATUS, WIFSIGNALED, WCOREDUMP, WIFSTOPPED, WSTOPSIG, WIFCONTINUED}\n\
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1194 @end deftypefn")
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1195 {
20856
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1196 if (args.length () != 1)
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1197 print_usage ();
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1198
20856
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1199 int status = args(0).xint_value ("WTERMSIG: STATUS must be an integer");
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1200
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20923
diff changeset
1201 return ovl (octave_wait::termsig (status));
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1202 }
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1203
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1204 DEFUNX ("WCOREDUMP", FWCOREDUMP, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1205 "-*- texinfo -*-\n\
20853
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20819
diff changeset
1206 @deftypefn {} {} WCOREDUMP (@var{status})\n\
20172
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
1207 Given @var{status} from a call to @code{waitpid}, return\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
1208 true if the child produced a core dump.\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
1209 \n\
20181
aa36fb998a4d maint: Remove unnecessary whitespace at end of lines.
Rik <rik@octave.org>
parents: 20172
diff changeset
1210 This function should only be employed if @code{WIFSIGNALED} returned true.\n\
20172
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
1211 The macro used to implement this function is not specified in POSIX.1-2001\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
1212 and is not available on some Unix implementations (e.g., AIX, SunOS).\n\
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1213 @seealso{waitpid, WIFEXITED, WEXITSTATUS, WIFSIGNALED, WTERMSIG, WIFSTOPPED, WSTOPSIG, WIFCONTINUED}\n\
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1214 @end deftypefn")
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1215 {
20856
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1216 if (args.length () != 1)
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1217 print_usage ();
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1218
20856
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1219 int status = args(0).xint_value ("WCOREDUMP: STATUS must be an integer");
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1220
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20923
diff changeset
1221 return ovl (octave_wait::coredump (status));
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1222 }
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1223
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1224 DEFUNX ("WIFSTOPPED", FWIFSTOPPED, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1225 "-*- texinfo -*-\n\
20853
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20819
diff changeset
1226 @deftypefn {} {} WIFSTOPPED (@var{status})\n\
20172
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
1227 Given @var{status} from a call to @code{waitpid}, return\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
1228 true if the child process was stopped by delivery of a signal.\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
1229 \n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
1230 This is only possible if the call was done using @code{WUNTRACED} or when\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
1231 the child is being traced (see ptrace(2)).\n\
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1232 @seealso{waitpid, WIFEXITED, WEXITSTATUS, WIFSIGNALED, WTERMSIG, WCOREDUMP, WSTOPSIG, WIFCONTINUED}\n\
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1233 @end deftypefn")
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1234 {
20856
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1235 if (args.length () != 1)
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1236 print_usage ();
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1237
20856
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1238 int status = args(0).xint_value ("WIFSTOPPED: STATUS must be an integer");
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1239
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20923
diff changeset
1240 return ovl (octave_wait::ifstopped (status));
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1241 }
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1242
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1243 DEFUNX ("WSTOPSIG", FWSTOPSIG, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1244 "-*- texinfo -*-\n\
20853
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20819
diff changeset
1245 @deftypefn {} {} WSTOPSIG (@var{status})\n\
20172
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
1246 Given @var{status} from a call to @code{waitpid}, return\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
1247 the number of the signal which caused the child to stop.\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
1248 \n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
1249 This function should only be employed if @code{WIFSTOPPED} returned true.\n\
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1250 @seealso{waitpid, WIFEXITED, WEXITSTATUS, WIFSIGNALED, WTERMSIG, WCOREDUMP, WIFSTOPPED, WIFCONTINUED}\n\
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1251 @end deftypefn")
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1252 {
20856
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1253 if (args.length () != 1)
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1254 print_usage ();
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1255
20856
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1256 int status = args(0).xint_value ("WSTOPSIG: STATUS must be an integer");
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1257
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20923
diff changeset
1258 return ovl (octave_wait::stopsig (status));
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1259 }
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1260
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1261 DEFUNX ("WIFCONTINUED", FWIFCONTINUED, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1262 "-*- texinfo -*-\n\
20853
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20819
diff changeset
1263 @deftypefn {} {} WIFCONTINUED (@var{status})\n\
20172
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
1264 Given @var{status} from a call to @code{waitpid}, return\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
1265 true if the child process was resumed by delivery of @code{SIGCONT}.\n\
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1266 @seealso{waitpid, WIFEXITED, WEXITSTATUS, WIFSIGNALED, WTERMSIG, WCOREDUMP, WIFSTOPPED, WSTOPSIG}\n\
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1267 @end deftypefn")
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1268 {
20856
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1269 if (args.length () != 1)
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1270 print_usage ();
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1271
20856
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1272 int status = args(0).xint_value ("WIFCONTINUED: STATUS must be an integer");
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1273
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20923
diff changeset
1274 return ovl (octave_wait::ifcontinued (status));
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1275 }
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1276
10249
14eba566f9f0 use DEFUNX instead of DEFUN for canonicalize_file_name
John W. Eaton <jwe@octave.org>
parents: 10197
diff changeset
1277 DEFUNX ("canonicalize_file_name", Fcanonicalize_file_name, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1278 "-*- texinfo -*-\n\
20853
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20819
diff changeset
1279 @deftypefn {} {[@var{cname}, @var{status}, @var{msg}] =} canonicalize_file_name (@var{fname})\n\
20172
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
1280 Return the canonical name of file @var{fname}.\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
1281 \n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
1282 If the file does not exist the empty string (\"\") is returned.\n\
14819
67b6b47a22f6 doc: Clarify docstrings for canonicalize_file_name, make_absolute_filename
Rik <octave@nomad.inbox5.com>
parents: 14429
diff changeset
1283 @seealso{make_absolute_filename, is_absolute_filename, is_rooted_relative_filename}\n\
5138
5fa9670b5956 [project @ 2005-02-09 23:13:03 by jwe]
jwe
parents: 5040
diff changeset
1284 @end deftypefn")
5fa9670b5956 [project @ 2005-02-09 23:13:03 by jwe]
jwe
parents: 5040
diff changeset
1285 {
20856
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1286 if (args.length () != 1)
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5775
diff changeset
1287 print_usage ();
5138
5fa9670b5956 [project @ 2005-02-09 23:13:03 by jwe]
jwe
parents: 5040
diff changeset
1288
20856
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1289 std::string name = args(0).xstring_value ("canonicalize_file_name: NAME must be a string");
20887
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
1290
20856
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1291 std::string msg;
20581
fd0efcdb3718 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20560
diff changeset
1292
21733
cb0fdd941d84 use namespace for system file_ops class
John W. Eaton <jwe@octave.org>
parents: 21732
diff changeset
1293 std::string result = octave::sys::canonicalize_file_name (name, msg);
20856
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1294
20887
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
1295 return ovl (result, msg.empty () ? 0 : -1, msg);
5138
5fa9670b5956 [project @ 2005-02-09 23:13:03 by jwe]
jwe
parents: 5040
diff changeset
1296 }
5fa9670b5956 [project @ 2005-02-09 23:13:03 by jwe]
jwe
parents: 5040
diff changeset
1297
20887
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
1298 static inline octave_value
7924
4976f66d469b miscellaneous cleanup
John W. Eaton <jwe@octave.org>
parents: 7096
diff changeset
1299 const_value (const octave_value_list& args, int val)
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1300 {
20887
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
1301 if (args.length () != 0)
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5775
diff changeset
1302 print_usage ();
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1303
20887
05125a9eb9c6 2015 Code Sprint: syscalls.cc: use ovl (), move print_usage to top of fcn.
Rik <rik@octave.org>
parents: 20856
diff changeset
1304 return octave_value (val);
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1305 }
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1306
21911
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1307 DEFUN (F_DUPFD, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1308 "-*- texinfo -*-\n\
20853
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20819
diff changeset
1309 @deftypefn {} {} F_DUPFD ()\n\
20172
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
1310 Return the numerical value to pass to @code{fcntl} to return\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
1311 a duplicate file descriptor.\n\
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1312 @seealso{fcntl, F_GETFD, F_GETFL, F_SETFD, F_SETFL}\n\
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1313 @end deftypefn")
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1314 {
21911
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1315 static int val = octave_f_dupfd_wrapper ();
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1316
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1317 if (val < 0)
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1318 err_disabled_feature ("F_DUPFD", "F_DUPFD");
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1319
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1320 return const_value (args, val);
14111
c5222658dc3c doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents: 14022
diff changeset
1321 }
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1322
21911
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1323 DEFUN (F_GETFD, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1324 "-*- texinfo -*-\n\
20853
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20819
diff changeset
1325 @deftypefn {} {} F_GETFD ()\n\
20172
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
1326 Return the numerical value to pass to @code{fcntl} to return\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
1327 the file descriptor flags.\n\
5333
ac8d64b9e76a [project @ 2005-05-02 18:15:20 by jwe]
jwe
parents: 5307
diff changeset
1328 @seealso{fcntl, F_DUPFD, F_GETFL, F_SETFD, F_SETFL}\n\
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1329 @end deftypefn")
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1330 {
21911
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1331 static int val = octave_f_getfd_wrapper ();
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1332
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1333 if (val < 0)
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1334 err_disabled_feature ("F_GETFD", "F_GETFD");
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1335
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1336 return const_value (args, val);
14111
c5222658dc3c doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents: 14022
diff changeset
1337 }
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1338
21911
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1339 DEFUN (F_GETFL, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1340 "-*- texinfo -*-\n\
20853
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20819
diff changeset
1341 @deftypefn {} {} F_GETFL ()\n\
20172
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
1342 Return the numerical value to pass to @code{fcntl} to return\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
1343 the file status flags.\n\
5333
ac8d64b9e76a [project @ 2005-05-02 18:15:20 by jwe]
jwe
parents: 5307
diff changeset
1344 @seealso{fcntl, F_DUPFD, F_GETFD, F_SETFD, F_SETFL}\n\
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1345 @end deftypefn")
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1346 {
21911
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1347 static int val = octave_f_getfl_wrapper ();
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1348
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1349 if (val < 0)
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1350 err_disabled_feature ("F_GETFL", "F_GETFL");
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1351
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1352 return const_value (args, val);
14111
c5222658dc3c doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents: 14022
diff changeset
1353 }
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1354
21911
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1355 DEFUN (F_SETFD, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1356 "-*- texinfo -*-\n\
20853
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20819
diff changeset
1357 @deftypefn {} {} F_SETFD ()\n\
14171
2ced2f59f523 doc: miscellaneous documentation improvements
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
1358 Return the numerical value to pass to @code{fcntl} to set the file\n\
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1359 descriptor flags.\n\
5333
ac8d64b9e76a [project @ 2005-05-02 18:15:20 by jwe]
jwe
parents: 5307
diff changeset
1360 @seealso{fcntl, F_DUPFD, F_GETFD, F_GETFL, F_SETFL}\n\
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1361 @end deftypefn")
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1362 {
21911
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1363 static int val = octave_f_setfd_wrapper ();
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1364
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1365 if (val < 0)
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1366 err_disabled_feature ("F_SETFD", "F_SETFD");
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1367
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1368 return const_value (args, val);
14111
c5222658dc3c doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents: 14022
diff changeset
1369 }
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1370
21911
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1371 DEFUN (F_SETFL, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1372 "-*- texinfo -*-\n\
20853
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20819
diff changeset
1373 @deftypefn {} {} F_SETFL ()\n\
14171
2ced2f59f523 doc: miscellaneous documentation improvements
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
1374 Return the numerical value to pass to @code{fcntl} to set the file\n\
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1375 status flags.\n\
5333
ac8d64b9e76a [project @ 2005-05-02 18:15:20 by jwe]
jwe
parents: 5307
diff changeset
1376 @seealso{fcntl, F_DUPFD, F_GETFD, F_GETFL, F_SETFD}\n\
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1377 @end deftypefn")
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1378 {
21911
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1379 static int val = octave_f_setfl_wrapper ();
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1380
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1381 if (val < 0)
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1382 err_disabled_feature ("F_SETFL", "F_SETFL");
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1383
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1384 return const_value (args, val);
14111
c5222658dc3c doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents: 14022
diff changeset
1385 }
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1386
21911
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1387 DEFUN (O_APPEND, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1388 "-*- texinfo -*-\n\
20853
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20819
diff changeset
1389 @deftypefn {} {} O_APPEND ()\n\
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1390 Return the numerical value of the file status flag that may be\n\
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1391 returned by @code{fcntl} to indicate each write operation appends,\n\
11152
39ae406df598 Improve docstrings for functions found in undocumented list.
Rik <octave@nomad.inbox5.com>
parents: 11006
diff changeset
1392 or that may be passed to @code{fcntl} to set the write mode to append.\n\
5333
ac8d64b9e76a [project @ 2005-05-02 18:15:20 by jwe]
jwe
parents: 5307
diff changeset
1393 @seealso{fcntl, O_ASYNC, O_CREAT, O_EXCL, O_NONBLOCK, O_RDONLY, O_RDWR, O_SYNC, O_TRUNC, O_WRONLY}\n\
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1394 @end deftypefn")
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1395 {
21911
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1396 static int val = octave_o_append_wrapper ();
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1397
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1398 if (val < 0)
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1399 err_disabled_feature ("O_APPEND", "O_APPEND");
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1400
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1401 return const_value (args, val);
14111
c5222658dc3c doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents: 14022
diff changeset
1402 }
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1403
21911
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1404 DEFUN (O_ASYNC, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1405 "-*- texinfo -*-\n\
20853
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20819
diff changeset
1406 @deftypefn {} {} O_ASYNC ()\n\
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1407 Return the numerical value of the file status flag that may be\n\
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1408 returned by @code{fcntl} to indicate asynchronous I/O.\n\
5333
ac8d64b9e76a [project @ 2005-05-02 18:15:20 by jwe]
jwe
parents: 5307
diff changeset
1409 @seealso{fcntl, O_APPEND, O_CREAT, O_EXCL, O_NONBLOCK, O_RDONLY, O_RDWR, O_SYNC, O_TRUNC, O_WRONLY}\n\
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1410 @end deftypefn")
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1411 {
21911
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1412 static int val = octave_o_async_wrapper ();
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1413
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1414 if (val < 0)
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1415 err_disabled_feature ("O_ASYNC", "O_ASYNC");
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1416
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1417 return const_value (args, val);
14111
c5222658dc3c doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents: 14022
diff changeset
1418 }
2669
c821858188b6 [project @ 1997-02-13 18:25:39 by jwe]
jwe
parents: 2475
diff changeset
1419
21911
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1420 DEFUN (O_CREAT, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1421 "-*- texinfo -*-\n\
20853
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20819
diff changeset
1422 @deftypefn {} {} O_CREAT ()\n\
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1423 Return the numerical value of the file status flag that may be\n\
20172
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
1424 returned by @code{fcntl} to indicate that a file should be created if it\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
1425 does not exist.\n\
5333
ac8d64b9e76a [project @ 2005-05-02 18:15:20 by jwe]
jwe
parents: 5307
diff changeset
1426 @seealso{fcntl, O_APPEND, O_ASYNC, O_EXCL, O_NONBLOCK, O_RDONLY, O_RDWR, O_SYNC, O_TRUNC, O_WRONLY}\n\
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1427 @end deftypefn")
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1428 {
21911
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1429 static int val = octave_o_creat_wrapper ();
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1430
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1431 if (val < 0)
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1432 err_disabled_feature ("O_CREAT", "O_CREAT");
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1433
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1434 return const_value (args, val);
14111
c5222658dc3c doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents: 14022
diff changeset
1435 }
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1436
21911
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1437 DEFUN (O_EXCL, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1438 "-*- texinfo -*-\n\
20853
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20819
diff changeset
1439 @deftypefn {} {} O_EXCL ()\n\
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1440 Return the numerical value of the file status flag that may be\n\
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1441 returned by @code{fcntl} to indicate that file locking is used.\n\
5333
ac8d64b9e76a [project @ 2005-05-02 18:15:20 by jwe]
jwe
parents: 5307
diff changeset
1442 @seealso{fcntl, O_APPEND, O_ASYNC, O_CREAT, O_NONBLOCK, O_RDONLY, O_RDWR, O_SYNC, O_TRUNC, O_WRONLY}\n\
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1443 @end deftypefn")
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1444 {
21911
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1445 static int val = octave_o_excl_wrapper ();
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1446
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1447 if (val < 0)
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1448 err_disabled_feature ("O_EXCL", "O_EXCL");
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1449
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1450 return const_value (args, val);
14111
c5222658dc3c doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents: 14022
diff changeset
1451 }
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1452
21911
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1453 DEFUN (O_NONBLOCK, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1454 "-*- texinfo -*-\n\
20853
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20819
diff changeset
1455 @deftypefn {} {} O_NONBLOCK ()\n\
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1456 Return the numerical value of the file status flag that may be\n\
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1457 returned by @code{fcntl} to indicate that non-blocking I/O is in use,\n\
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1458 or that may be passsed to @code{fcntl} to set non-blocking I/O.\n\
5333
ac8d64b9e76a [project @ 2005-05-02 18:15:20 by jwe]
jwe
parents: 5307
diff changeset
1459 @seealso{fcntl, O_APPEND, O_ASYNC, O_CREAT, O_EXCL, O_RDONLY, O_RDWR, O_SYNC, O_TRUNC, O_WRONLY}\n\
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1460 @end deftypefn")
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1461 {
21911
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1462 static int val = octave_o_nonblock_wrapper ();
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1463
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1464 if (val < 0)
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1465 err_disabled_feature ("O_NONBLOCK", "O_NONBLOCK");
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1466
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1467 return const_value (args, val);
14111
c5222658dc3c doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents: 14022
diff changeset
1468 }
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1469
21911
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1470 DEFUN (O_RDONLY, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1471 "-*- texinfo -*-\n\
20853
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20819
diff changeset
1472 @deftypefn {} {} O_RDONLY ()\n\
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1473 Return the numerical value of the file status flag that may be\n\
20172
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
1474 returned by @code{fcntl} to indicate that a file is open for reading only.\n\
5333
ac8d64b9e76a [project @ 2005-05-02 18:15:20 by jwe]
jwe
parents: 5307
diff changeset
1475 @seealso{fcntl, O_APPEND, O_ASYNC, O_CREAT, O_EXCL, O_NONBLOCK, O_RDWR, O_SYNC, O_TRUNC, O_WRONLY}\n\
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1476 @end deftypefn")
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1477 {
21911
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1478 static int val = octave_o_rdonly_wrapper ();
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1479
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1480 if (val < 0)
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1481 err_disabled_feature ("O_RDONLY", "O_RDONLY");
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1482
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1483 return const_value (args, val);
14111
c5222658dc3c doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents: 14022
diff changeset
1484 }
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1485
21911
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1486 DEFUN (O_RDWR, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1487 "-*- texinfo -*-\n\
20853
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20819
diff changeset
1488 @deftypefn {} {} O_RDWR ()\n\
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1489 Return the numerical value of the file status flag that may be\n\
20172
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
1490 returned by @code{fcntl} to indicate that a file is open for both reading\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
1491 and writing.\n\
5333
ac8d64b9e76a [project @ 2005-05-02 18:15:20 by jwe]
jwe
parents: 5307
diff changeset
1492 @seealso{fcntl, O_APPEND, O_ASYNC, O_CREAT, O_EXCL, O_NONBLOCK, O_RDONLY, O_SYNC, O_TRUNC, O_WRONLY}\n\
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1493 @end deftypefn")
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1494 {
21911
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1495 static int val = octave_o_rdwr_wrapper ();
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1496
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1497 if (val < 0)
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1498 err_disabled_feature ("O_RDWR", "O_RDWR");
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1499
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1500 return const_value (args, val);
14111
c5222658dc3c doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents: 14022
diff changeset
1501 }
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1502
21911
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1503 DEFUN (O_SYNC, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1504 "-*- texinfo -*-\n\
20853
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20819
diff changeset
1505 @deftypefn {} {} O_SYNC ()\n\
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1506 Return the numerical value of the file status flag that may be\n\
21547
ad0599a0acc6 doc: Wrap C++ docstrings to 79 characters + newline (80 total).
Rik <rik@octave.org>
parents: 21343
diff changeset
1507 returned by @code{fcntl} to indicate that a file is open for synchronous\n\
ad0599a0acc6 doc: Wrap C++ docstrings to 79 characters + newline (80 total).
Rik <rik@octave.org>
parents: 21343
diff changeset
1508 I/O.\n\
5333
ac8d64b9e76a [project @ 2005-05-02 18:15:20 by jwe]
jwe
parents: 5307
diff changeset
1509 @seealso{fcntl, O_APPEND, O_ASYNC, O_CREAT, O_EXCL, O_NONBLOCK, O_RDONLY, O_RDWR, O_TRUNC, O_WRONLY}\n\
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1510 @end deftypefn")
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1511 {
21911
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1512 static int val = octave_o_sync_wrapper ();
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1513
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1514 if (val < 0)
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1515 err_disabled_feature ("O_SYNC", "O_SYNC");
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1516
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1517 return const_value (args, val);
14111
c5222658dc3c doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents: 14022
diff changeset
1518 }
2669
c821858188b6 [project @ 1997-02-13 18:25:39 by jwe]
jwe
parents: 2475
diff changeset
1519
21911
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1520 DEFUN (O_TRUNC, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1521 "-*- texinfo -*-\n\
20853
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20819
diff changeset
1522 @deftypefn {} {} O_TRUNC ()\n\
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1523 Return the numerical value of the file status flag that may be\n\
20172
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
1524 returned by @code{fcntl} to indicate that if file exists, it should be\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
1525 truncated when writing.\n\
5333
ac8d64b9e76a [project @ 2005-05-02 18:15:20 by jwe]
jwe
parents: 5307
diff changeset
1526 @seealso{fcntl, O_APPEND, O_ASYNC, O_CREAT, O_EXCL, O_NONBLOCK, O_RDONLY, O_RDWR, O_SYNC, O_WRONLY}\n\
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1527 @end deftypefn")
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1528 {
21911
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1529 static int val = octave_o_trunc_wrapper ();
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1530
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1531 if (val < 0)
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1532 err_disabled_feature ("O_TRUNC", "O_TRUNC");
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1533
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1534 return const_value (args, val);
14111
c5222658dc3c doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents: 14022
diff changeset
1535 }
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1536
21911
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1537 DEFUN (O_WRONLY, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1538 "-*- texinfo -*-\n\
20853
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20819
diff changeset
1539 @deftypefn {} {} O_WRONLY ()\n\
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1540 Return the numerical value of the file status flag that may be\n\
20172
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
1541 returned by @code{fcntl} to indicate that a file is open for writing only.\n\
5333
ac8d64b9e76a [project @ 2005-05-02 18:15:20 by jwe]
jwe
parents: 5307
diff changeset
1542 @seealso{fcntl, O_APPEND, O_ASYNC, O_CREAT, O_EXCL, O_NONBLOCK, O_RDONLY, O_RDWR, O_SYNC, O_TRUNC}\n\
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1543 @end deftypefn")
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1544 {
21911
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1545 static int val = octave_o_wronly_wrapper ();
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1546
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1547 if (val < 0)
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1548 err_disabled_feature ("O_WRONLY", "O_WRONLY");
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1549
c66c156e1d1d hide fcntl.h header
John W. Eaton <jwe@octave.org>
parents: 21852
diff changeset
1550 return const_value (args, val);
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1551 }
3446
5ee5afb3981a [project @ 2000-01-17 09:42:43 by jwe]
jwe
parents: 3360
diff changeset
1552
20791
f7084eae3318 maint: Use Octave coding conventions for #if statements.
Rik <rik@octave.org>
parents: 20764
diff changeset
1553 #if ! defined (WNOHANG)
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1554 #define WNOHANG 0
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1555 #endif
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1556
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1557 DEFUNX ("WNOHANG", FWNOHANG, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1558 "-*- texinfo -*-\n\
20853
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20819
diff changeset
1559 @deftypefn {} {} WNOHANG ()\n\
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1560 Return the numerical value of the option argument that may be\n\
20172
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
1561 passed to @code{waitpid} to indicate that it should return its status\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
1562 immediately instead of waiting for a process to exit.\n\
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1563 @seealso{waitpid, WUNTRACED, WCONTINUE}\n\
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1564 @end deftypefn")
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1565 {
7924
4976f66d469b miscellaneous cleanup
John W. Eaton <jwe@octave.org>
parents: 7096
diff changeset
1566 return const_value (args, WNOHANG);
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1567 }
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1568
20791
f7084eae3318 maint: Use Octave coding conventions for #if statements.
Rik <rik@octave.org>
parents: 20764
diff changeset
1569 #if ! defined (WUNTRACED)
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1570 #define WUNTRACED 0
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1571 #endif
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1572
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1573 DEFUNX ("WUNTRACED", FWUNTRACED, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1574 "-*- texinfo -*-\n\
20853
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20819
diff changeset
1575 @deftypefn {} {} WUNTRACED ()\n\
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1576 Return the numerical value of the option argument that may be\n\
20172
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
1577 passed to @code{waitpid} to indicate that it should also return if the child\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
1578 process has stopped but is not traced via the @code{ptrace} system call\n\
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1579 @seealso{waitpid, WNOHANG, WCONTINUE}\n\
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1580 @end deftypefn")
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1581 {
7924
4976f66d469b miscellaneous cleanup
John W. Eaton <jwe@octave.org>
parents: 7096
diff changeset
1582 return const_value (args, WUNTRACED);
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1583 }
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1584
20791
f7084eae3318 maint: Use Octave coding conventions for #if statements.
Rik <rik@octave.org>
parents: 20764
diff changeset
1585 #if ! defined (WCONTINUE)
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1586 #define WCONTINUE 0
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1587 #endif
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1588
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1589 DEFUNX ("WCONTINUE", FWCONTINUE, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1590 "-*- texinfo -*-\n\
20853
1142cf6abc0d 2015 Code Sprint: remove class of function from docstring for all C++ files.
Rik <rik@octave.org>
parents: 20819
diff changeset
1591 @deftypefn {} {} WCONTINUE ()\n\
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1592 Return the numerical value of the option argument that may be\n\
20172
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
1593 passed to @code{waitpid} to indicate that it should also return if a stopped\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
1594 child has been resumed by delivery of a @code{SIGCONT} signal.\n\
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1595 @seealso{waitpid, WNOHANG, WUNTRACED}\n\
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1596 @end deftypefn")
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1597 {
7924
4976f66d469b miscellaneous cleanup
John W. Eaton <jwe@octave.org>
parents: 7096
diff changeset
1598 return const_value (args, WCONTINUE);
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1599 }