annotate libinterp/corefcn/syscalls.cc @ 20856:b3a18c764161

Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
author Yu Liu <yul.liuiyu@gmail.com>
date Sat, 12 Dec 2015 10:54:20 -0500
parents 1142cf6abc0d
children 05125a9eb9c6
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
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
29 #ifdef HAVE_CONFIG_H
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
30 #include <config.h>
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
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
36 #include <sys/types.h>
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
37 #include <unistd.h>
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
38
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
39 #include <fcntl.h>
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
40
17236
6a6e3f1a824c save history on exec (bug #39734)
John W. Eaton <jwe@octave.org>
parents: 15221
diff changeset
41 #include "cmd-hist.h"
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2902
diff changeset
42 #include "file-ops.h"
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2902
diff changeset
43 #include "file-stat.h"
11006
aca961a3f387 provide gethostname function
John W. Eaton <jwe@octave.org>
parents: 10840
diff changeset
44 #include "oct-env.h"
2937
9d26524e2869 [project @ 1997-05-06 05:49:53 by jwe]
jwe
parents: 2926
diff changeset
45 #include "oct-syscalls.h"
5547
8b0b36c2dc0c [project @ 2005-11-29 17:41:33 by jwe]
jwe
parents: 5476
diff changeset
46 #include "oct-uname.h"
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2902
diff changeset
47
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
48 #include "defun.h"
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
49 #include "error.h"
2078
4d43f960f2cc [project @ 1996-04-24 01:12:59 by jwe]
jwe
parents: 2075
diff changeset
50 #include "gripes.h"
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
51 #include "lo-utils.h"
17236
6a6e3f1a824c save history on exec (bug #39734)
John W. Eaton <jwe@octave.org>
parents: 15221
diff changeset
52 #include "oct-hist.h"
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
53 #include "oct-map.h"
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
54 #include "oct-obj.h"
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
55 #include "oct-stdstrm.h"
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
56 #include "oct-stream.h"
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
57 #include "sysdep.h"
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
58 #include "utils.h"
2366
c90105b99479 [project @ 1996-10-11 23:22:27 by jwe]
jwe
parents: 2305
diff changeset
59 #include "variables.h"
6321
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 5872
diff changeset
60 #include "input.h"
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
61
10762
d53eb6249892 use scalar map in some syscalls
Jaroslav Hajek <highegg@gmail.com>
parents: 10521
diff changeset
62 static octave_scalar_map
8549
424ba638d8f1 [mq]: fstat
file-io.cc (Ffstat): new function
parents: 8286
diff changeset
63 mk_stat_map (const base_file_stat& fs)
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
64 {
10762
d53eb6249892 use scalar map in some syscalls
Jaroslav Hajek <highegg@gmail.com>
parents: 10521
diff changeset
65 octave_scalar_map m;
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
66
4675
f6d6335c08f6 [project @ 2003-12-16 05:11:26 by jwe]
jwe
parents: 4371
diff changeset
67 m.assign ("dev", static_cast<double> (fs.dev ()));
f6d6335c08f6 [project @ 2003-12-16 05:11:26 by jwe]
jwe
parents: 4371
diff changeset
68 m.assign ("ino", fs.ino ());
5476
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
69 m.assign ("mode", fs.mode ());
4675
f6d6335c08f6 [project @ 2003-12-16 05:11:26 by jwe]
jwe
parents: 4371
diff changeset
70 m.assign ("modestr", fs.mode_as_string ());
f6d6335c08f6 [project @ 2003-12-16 05:11:26 by jwe]
jwe
parents: 4371
diff changeset
71 m.assign ("nlink", fs.nlink ());
f6d6335c08f6 [project @ 2003-12-16 05:11:26 by jwe]
jwe
parents: 4371
diff changeset
72 m.assign ("uid", fs.uid ());
f6d6335c08f6 [project @ 2003-12-16 05:11:26 by jwe]
jwe
parents: 4371
diff changeset
73 m.assign ("gid", fs.gid ());
3887
7da18459c08b [project @ 2002-04-04 00:44:21 by jwe]
jwe
parents: 3715
diff changeset
74 #if defined (HAVE_STRUCT_STAT_ST_RDEV)
4675
f6d6335c08f6 [project @ 2003-12-16 05:11:26 by jwe]
jwe
parents: 4371
diff changeset
75 m.assign ("rdev", static_cast<double> (fs.rdev ()));
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
76 #endif
4675
f6d6335c08f6 [project @ 2003-12-16 05:11:26 by jwe]
jwe
parents: 4371
diff changeset
77 m.assign ("size", fs.size ());
f6d6335c08f6 [project @ 2003-12-16 05:11:26 by jwe]
jwe
parents: 4371
diff changeset
78 m.assign ("atime", fs.atime ());
f6d6335c08f6 [project @ 2003-12-16 05:11:26 by jwe]
jwe
parents: 4371
diff changeset
79 m.assign ("mtime", fs.mtime ());
f6d6335c08f6 [project @ 2003-12-16 05:11:26 by jwe]
jwe
parents: 4371
diff changeset
80 m.assign ("ctime", fs.ctime ());
3887
7da18459c08b [project @ 2002-04-04 00:44:21 by jwe]
jwe
parents: 3715
diff changeset
81 #if defined (HAVE_STRUCT_STAT_ST_BLKSIZE)
4675
f6d6335c08f6 [project @ 2003-12-16 05:11:26 by jwe]
jwe
parents: 4371
diff changeset
82 m.assign ("blksize", fs.blksize ());
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
83 #endif
3887
7da18459c08b [project @ 2002-04-04 00:44:21 by jwe]
jwe
parents: 3715
diff changeset
84 #if defined (HAVE_STRUCT_STAT_ST_BLOCKS)
4675
f6d6335c08f6 [project @ 2003-12-16 05:11:26 by jwe]
jwe
parents: 4371
diff changeset
85 m.assign ("blocks", fs.blocks ());
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
86 #endif
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
87
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
88 return m;
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
89 }
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
90
10336
1603dfe72933 obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
91 static octave_value_list
1603dfe72933 obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
92 mk_stat_result (const base_file_stat& fs)
1603dfe72933 obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
93 {
1603dfe72933 obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
94 octave_value_list retval;
1603dfe72933 obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
95
1603dfe72933 obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
96 if (fs)
1603dfe72933 obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
97 {
1603dfe72933 obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
98 retval(2) = std::string ();
1603dfe72933 obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
99 retval(1) = 0;
1603dfe72933 obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
100 retval(0) = octave_value (mk_stat_map (fs));
1603dfe72933 obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
101 }
1603dfe72933 obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
102 else
1603dfe72933 obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
103 {
1603dfe72933 obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
104 retval(2) = fs.error ();
1603dfe72933 obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
105 retval(1) = -1;
1603dfe72933 obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
106 retval(0) = Matrix ();
1603dfe72933 obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
107 }
1603dfe72933 obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
108
1603dfe72933 obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
109 return retval;
1603dfe72933 obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
110 }
1603dfe72933 obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
111
10299
c992efc0c2fa use DEFUNX instead of DEFUN for all functions in syscalls.cc
John W. Eaton <jwe@octave.org>
parents: 10259
diff changeset
112 DEFUNX ("dup2", Fdup2, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
113 "-*- 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
114 @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
115 Duplicate a file descriptor.\n\
c821858188b6 [project @ 1997-02-13 18:25:39 by jwe]
jwe
parents: 2475
diff changeset
116 \n\
20172
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
117 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
118 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
119 error message.\n\
19109
e90bfaadb489 doc: Increase seealso links between low level C IO functions.
Rik <rik@octave.org>
parents: 18112
diff changeset
120 @seealso{fopen, fclose, fcntl}\n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
121 @end deftypefn")
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
122 {
2669
c821858188b6 [project @ 1997-02-13 18:25:39 by jwe]
jwe
parents: 2475
diff changeset
123 octave_value_list retval;
c821858188b6 [project @ 1997-02-13 18:25:39 by jwe]
jwe
parents: 2475
diff changeset
124
3523
b80bbb43a1a9 [project @ 2000-02-02 10:25:52 by jwe]
jwe
parents: 3458
diff changeset
125 retval(1) = std::string ();
4294
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4254
diff changeset
126 retval(0) = -1;
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
127
20819
f428cbe7576f eliminate unnecessary uses of nargin
John W. Eaton <jwe@octave.org>
parents: 20800
diff changeset
128 if (args.length () != 2)
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
129 print_usage ();
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
130
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
131 octave_stream old_stream
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
132 = octave_stream_list::lookup (args(0), "dup2");
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
133
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
134 octave_stream new_stream
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
135 = octave_stream_list::lookup (args(1), "dup2");
2937
9d26524e2869 [project @ 1997-05-06 05:49:53 by jwe]
jwe
parents: 2926
diff changeset
136
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
137 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
138 int i_new = new_stream.file_number ();
20741
a5ab31b52ae8 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20704
diff changeset
139
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
140 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
141 {
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
142 std::string msg;
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
143
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
144 int status = octave_syscalls::dup2 (i_old, i_new, msg);
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
145
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
146 retval(1) = msg;
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
147 retval(0) = status;
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
148 }
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 return retval;
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
151 }
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
152
10299
c992efc0c2fa use DEFUNX instead of DEFUN for all functions in syscalls.cc
John W. Eaton <jwe@octave.org>
parents: 10259
diff changeset
153 DEFUNX ("exec", Fexec, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
154 "-*- 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
155 @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
156 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
157 \n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
158 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
159 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
160 For example,\n\
2669
c821858188b6 [project @ 1997-02-13 18:25:39 by jwe]
jwe
parents: 2475
diff changeset
161 \n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
162 @example\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
163 exec (\"ls\" \"-l\")\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
164 @end example\n\
2669
c821858188b6 [project @ 1997-02-13 18:25:39 by jwe]
jwe
parents: 2475
diff changeset
165 \n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
166 @noindent\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
167 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
168 \n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
169 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
170 @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
171 error message.\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
172 @end deftypefn")
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
173 {
2669
c821858188b6 [project @ 1997-02-13 18:25:39 by jwe]
jwe
parents: 2475
diff changeset
174 octave_value_list retval;
c821858188b6 [project @ 1997-02-13 18:25:39 by jwe]
jwe
parents: 2475
diff changeset
175
3523
b80bbb43a1a9 [project @ 2000-02-02 10:25:52 by jwe]
jwe
parents: 3458
diff changeset
176 retval(1) = std::string ();
4294
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4254
diff changeset
177 retval(0) = -1;
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
178
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
179 int nargin = args.length ();
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
180
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
181 if (nargin < 1 || nargin > 2)
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
182 print_usage ();
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
183
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
184 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
185
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
186 string_vector exec_args;
20704
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20700
diff changeset
187
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
188 if (nargin == 2)
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
189 {
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
190 string_vector tmp = args(1).xall_strings ("exec: all arguments must be strings");
20581
fd0efcdb3718 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20560
diff changeset
191
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
192 int len = tmp.numel ();
20581
fd0efcdb3718 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20560
diff changeset
193
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
194 exec_args.resize (len + 1);
20581
fd0efcdb3718 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20560
diff changeset
195
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
196 exec_args[0] = exec_file;
20581
fd0efcdb3718 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20560
diff changeset
197
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
198 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
199 exec_args[i+1] = tmp[i];
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
200 }
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
201 else
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
202 {
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
203 exec_args.resize (1);
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
204
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
205 exec_args[0] = exec_file;
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
206 }
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
207
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
208 octave_history_write_timestamp ();
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
209
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
210 if (! command_history::ignoring_entries ())
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
211 command_history::clean_up_and_save ();
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
212
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
213 std::string msg;
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
214
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
215 int status = octave_syscalls::execvp (exec_file, exec_args, msg);
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
216
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
217 retval(1) = msg;
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
218 retval(0) = status;
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
219
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
220 return retval;
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
221 }
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
222
10299
c992efc0c2fa use DEFUNX instead of DEFUN for all functions in syscalls.cc
John W. Eaton <jwe@octave.org>
parents: 10259
diff changeset
223 DEFUNX ("popen2", Fpopen2, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
224 "-*- 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
225 @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
226 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
227 \n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
228 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
229 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
230 \n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
231 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
232 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
233 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
234 @var{pid} is @minus{}1.\n\
6321
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 5872
diff changeset
235 \n\
10840
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10791
diff changeset
236 For example:\n\
6321
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 5872
diff changeset
237 \n\
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 5872
diff changeset
238 @example\n\
6923
1fcee6e2c4d3 [project @ 2007-09-25 16:57:12 by jwe]
jwe
parents: 6678
diff changeset
239 [in, out, pid] = popen2 (\"sort\", \"-r\");\n\
6321
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 5872
diff changeset
240 fputs (in, \"these\\nare\\nsome\\nstrings\\n\");\n\
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 5872
diff changeset
241 fclose (in);\n\
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 5872
diff changeset
242 EAGAIN = errno (\"EAGAIN\");\n\
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 5872
diff changeset
243 done = false;\n\
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 5872
diff changeset
244 do\n\
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 5872
diff changeset
245 s = fgets (out);\n\
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 5872
diff changeset
246 if (ischar (s))\n\
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 5872
diff changeset
247 fputs (stdout, s);\n\
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 5872
diff changeset
248 elseif (errno () == EAGAIN)\n\
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 5872
diff changeset
249 sleep (0.1);\n\
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 5872
diff changeset
250 fclear (out);\n\
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 5872
diff changeset
251 else\n\
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 5872
diff changeset
252 done = true;\n\
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 5872
diff changeset
253 endif\n\
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 5872
diff changeset
254 until (done)\n\
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 5872
diff changeset
255 fclose (out);\n\
9563
f5c28d8f5147 syscalls.cc: Recommend waitpid() in popen2() documentation.
Rob Mahurin <rob@utk.edu>
parents: 9209
diff changeset
256 waitpid (pid);\n\
14360
97883071e8e4 doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents: 14171
diff changeset
257 \n\
97883071e8e4 doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents: 14171
diff changeset
258 @print{} these\n\
97883071e8e4 doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents: 14171
diff changeset
259 @print{} strings\n\
97883071e8e4 doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents: 14171
diff changeset
260 @print{} some\n\
97883071e8e4 doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents: 14171
diff changeset
261 @print{} are\n\
6321
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 5872
diff changeset
262 @end example\n\
9563
f5c28d8f5147 syscalls.cc: Recommend waitpid() in popen2() documentation.
Rob Mahurin <rob@utk.edu>
parents: 9209
diff changeset
263 \n\
17968
43c199e83ed7 Reap child process in popen2 %!test block.
Rik <rik@octave.org>
parents: 17951
diff changeset
264 Note that @code{popen2}, unlike @code{popen}, will not @nospell{\"reap\"} the\n\
9563
f5c28d8f5147 syscalls.cc: Recommend waitpid() in popen2() documentation.
Rob Mahurin <rob@utk.edu>
parents: 9209
diff changeset
265 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
266 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
267 @seealso{popen, waitpid}\n\
6321
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 5872
diff changeset
268 @end deftypefn")
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 5872
diff changeset
269 {
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 5872
diff changeset
270 octave_value_list retval;
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 5872
diff changeset
271
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 5872
diff changeset
272 retval(2) = -1;
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 5872
diff changeset
273 retval(1) = Matrix ();
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 5872
diff changeset
274 retval(0) = Matrix ();
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 5872
diff changeset
275
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 5872
diff changeset
276 int nargin = args.length ();
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 5872
diff changeset
277
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
278 if (nargin < 1 || nargin > 3)
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
279 print_usage ();
6321
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 5872
diff changeset
280
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
281 std::string exec_file = args(0).xstring_value ("popen2: COMMAND argument must be a string");
20704
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20700
diff changeset
282
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
283 string_vector arg_list;
20704
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20700
diff changeset
284
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
285 if (nargin >= 2)
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
286 {
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
287 string_vector tmp = args(1).xall_strings ("popen2: all arguments must be strings");
20581
fd0efcdb3718 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20560
diff changeset
288
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
289 int len = tmp.numel ();
20581
fd0efcdb3718 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20560
diff changeset
290
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
291 arg_list.resize (len + 1);
20581
fd0efcdb3718 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20560
diff changeset
292
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
293 arg_list[0] = exec_file;
20704
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20700
diff changeset
294
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
295 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
296 arg_list[i+1] = tmp[i];
6321
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 5872
diff changeset
297 }
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 5872
diff changeset
298 else
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
299 {
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
300 arg_list.resize (1);
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
301
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
302 arg_list[0] = exec_file;
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
303 }
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
304
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
305 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
306
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
307 int fildes[2];
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
308 std::string msg;
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
309 pid_t pid;
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
310
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
311 pid = octave_syscalls::popen2 (exec_file, arg_list, sync_mode,
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
312 fildes, msg, interactive);
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
313 if (pid >= 0)
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
314 {
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
315 FILE *ifile = fdopen (fildes[1], "r");
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
316 FILE *ofile = fdopen (fildes[0], "w");
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
317
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
318 std::string nm;
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
319
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
320 octave_stream is = octave_stdiostream::create (exec_file + "-in",
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
321 ifile,
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
322 std::ios::in);
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
323
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
324 octave_stream os = octave_stdiostream::create (exec_file + "-out",
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
325 ofile,
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
326 std::ios::out);
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
327
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
328 Cell file_ids (1, 2);
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
329
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
330 retval(2) = pid;
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
331 retval(1) = octave_stream_list::insert (is);
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
332 retval(0) = octave_stream_list::insert (os);
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
333 }
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
334 else
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
335 error (msg.c_str ());
6321
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 5872
diff changeset
336
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 5872
diff changeset
337 return retval;
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 5872
diff changeset
338 }
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 5872
diff changeset
339
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 5872
diff changeset
340 /*
18022
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
341
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
342 %!test # UNIX-style test
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
343 %! if (isunix () || ismac ())
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
344 %! [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
345 %! EAGAIN = errno ("EAGAIN");
18022
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
346 %! fputs (in, "these\nare\nsome\nstrings\n");
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
347 %! fclose (in);
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
348 %! done = false;
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
349 %! str = {};
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
350 %! idx = 0;
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
351 %! errs = 0;
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
352 %! do
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
353 %! if (ismac ()) # FIXME: Is this necessary?
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
354 %! errno (0);
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
355 %! endif
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
356 %! s = fgets (out);
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
357 %! if (ischar (s))
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
358 %! idx++;
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
359 %! str{idx} = s;
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
360 %! elseif (errno () == EAGAIN)
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
361 %! fclear (out);
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
362 %! sleep (0.1);
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
363 %! if (++errs == 100)
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
364 %! done = true;
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
365 %! endif
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
366 %! else
6321
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 5872
diff changeset
367 %! done = true;
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 5872
diff changeset
368 %! endif
18022
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
369 %! until (done)
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
370 %! fclose (out);
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
371 %! waitpid (pid);
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
372 %! 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
373 %! endif
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
374
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
375 %!test # Windows-style test
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
376 %! if (ispc () && ! isunix ())
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
377 %! [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
378 %! EAGAIN = errno ("EINVAL");
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
379 %! 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
380 %! fclose (in);
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
381 %! done = false;
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
382 %! str = {};
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
383 %! idx = 0;
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
384 %! errs = 0;
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
385 %! do
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
386 %! errno (0);
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
387 %! s = fgets (out);
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
388 %! if (ischar (s))
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
389 %! idx++;
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
390 %! str{idx} = s;
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
391 %! elseif (errno () == EAGAIN)
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
392 %! fclear (out);
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
393 %! sleep (0.1);
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
394 %! if (++errs == 100)
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
395 %! done = true;
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
396 %! endif
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
397 %! else
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
398 %! done = true;
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
399 %! endif
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
400 %! until (done)
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
401 %! fclose (out);
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
402 %! waitpid (pid);
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
403 %! 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
404 %! endif
18022
c3cd335bd71b Rewrite failing popen2 test for Windows (bug #40606).
Rik <rik@octave.org>
parents: 17969
diff changeset
405
6321
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 5872
diff changeset
406 */
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 5872
diff changeset
407
10259
65b41bc71f09 use gnulib fcntl module
John W. Eaton <jwe@octave.org>
parents: 10252
diff changeset
408 DEFUNX ("fcntl", Ffcntl, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
409 "-*- 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
410 @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
411 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
412 \n\
e90bfaadb489 doc: Increase seealso links between low level C IO functions.
Rik <rik@octave.org>
parents: 18112
diff changeset
413 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
414 \n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
415 @vtable @code\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
416 @item F_DUPFD\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
417 Return a duplicate file descriptor.\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
418 \n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
419 @item F_GETFD\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
420 Return the file descriptor flags for @var{fid}.\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
421 \n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
422 @item F_SETFD\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
423 Set the file descriptor flags for @var{fid}.\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
424 \n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
425 @item F_GETFL\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
426 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
427 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
428 \n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
429 @vtable @code\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
430 @item O_RDONLY\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
431 Open for reading only.\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
432 \n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
433 @item O_WRONLY\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
434 Open for writing only.\n\
2669
c821858188b6 [project @ 1997-02-13 18:25:39 by jwe]
jwe
parents: 2475
diff changeset
435 \n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
436 @item O_RDWR\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
437 Open for reading and writing.\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
438 \n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
439 @item O_APPEND\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
440 Append on each write.\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
441 \n\
5040
b6ff3a0d3d17 [project @ 2004-09-27 13:50:01 by jwe]
jwe
parents: 4928
diff changeset
442 @item O_CREAT\n\
b6ff3a0d3d17 [project @ 2004-09-27 13:50:01 by jwe]
jwe
parents: 4928
diff changeset
443 Create the file if it does not exist.\n\
b6ff3a0d3d17 [project @ 2004-09-27 13:50:01 by jwe]
jwe
parents: 4928
diff changeset
444 \n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
445 @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
446 Non-blocking mode.\n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
447 \n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
448 @item O_SYNC\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
449 Wait for writes to complete.\n\
2669
c821858188b6 [project @ 1997-02-13 18:25:39 by jwe]
jwe
parents: 2475
diff changeset
450 \n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
451 @item O_ASYNC\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
452 Asynchronous I/O.\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
453 @end vtable\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
454 \n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
455 @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
456 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
457 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
458 @w{@code{O_NONBLOCK}}.\n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
459 @end vtable\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
460 \n\
20172
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
461 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
462 @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
463 message.\n\
19109
e90bfaadb489 doc: Increase seealso links between low level C IO functions.
Rik <rik@octave.org>
parents: 18112
diff changeset
464 @seealso{fopen, dup2}\n\
3301
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 {
2669
c821858188b6 [project @ 1997-02-13 18:25:39 by jwe]
jwe
parents: 2475
diff changeset
467 octave_value_list retval;
c821858188b6 [project @ 1997-02-13 18:25:39 by jwe]
jwe
parents: 2475
diff changeset
468
3523
b80bbb43a1a9 [project @ 2000-02-02 10:25:52 by jwe]
jwe
parents: 3458
diff changeset
469 retval(1) = std::string ();
4294
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4254
diff changeset
470 retval(0) = -1;
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
471
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
472 int nargin = args.length ();
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
473
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
474 if (nargin != 3)
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
475 print_usage ();
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
476
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
477 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
478
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
479 int fid = strm.file_number ();
3715
e5ff21d2bac6 [project @ 2000-09-01 05:52:56 by jwe]
jwe
parents: 3531
diff changeset
480
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
481 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
482 int arg = args(2).int_value (true);
3715
e5ff21d2bac6 [project @ 2000-09-01 05:52:56 by jwe]
jwe
parents: 3531
diff changeset
483
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
484 // FIXME: Need better checking here?
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
485 if (fid < 0)
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
486 error ("fcntl: invalid file id");
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
487 else
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
488 {
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
489 std::string msg;
2937
9d26524e2869 [project @ 1997-05-06 05:49:53 by jwe]
jwe
parents: 2926
diff changeset
490
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
491 int status = octave_fcntl (fid, req, arg, msg);
2669
c821858188b6 [project @ 1997-02-13 18:25:39 by jwe]
jwe
parents: 2475
diff changeset
492
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
493 retval(1) = msg;
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
494 retval(0) = status;
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
495 }
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
496
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
497 return retval;
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
498 }
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
499
10299
c992efc0c2fa use DEFUNX instead of DEFUN for all functions in syscalls.cc
John W. Eaton <jwe@octave.org>
parents: 10259
diff changeset
500 DEFUNX ("fork", Ffork, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
501 "-*- 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
502 @deftypefn {} {[@var{pid}, @var{msg}] =} fork ()\n\
2669
c821858188b6 [project @ 1997-02-13 18:25:39 by jwe]
jwe
parents: 2475
diff changeset
503 Create a copy of the current process.\n\
c821858188b6 [project @ 1997-02-13 18:25:39 by jwe]
jwe
parents: 2475
diff changeset
504 \n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
505 Fork can return one of the following values:\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
506 \n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
507 @table @asis\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
508 @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
509 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
510 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
511 any child processes to exit.\n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
512 \n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
513 @item 0\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
514 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
515 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
516 \n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
517 @item < 0\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
518 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
519 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
520 @end table\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
521 @end deftypefn")
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
522 {
2669
c821858188b6 [project @ 1997-02-13 18:25:39 by jwe]
jwe
parents: 2475
diff changeset
523 octave_value_list retval;
c821858188b6 [project @ 1997-02-13 18:25:39 by jwe]
jwe
parents: 2475
diff changeset
524
3523
b80bbb43a1a9 [project @ 2000-02-02 10:25:52 by jwe]
jwe
parents: 3458
diff changeset
525 retval(1) = std::string ();
4294
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4254
diff changeset
526 retval(0) = -1;
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
527
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
528 int nargin = args.length ();
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
529
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
530 if (nargin != 0)
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
531 print_usage ();
2937
9d26524e2869 [project @ 1997-05-06 05:49:53 by jwe]
jwe
parents: 2926
diff changeset
532
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
533 std::string msg;
2669
c821858188b6 [project @ 1997-02-13 18:25:39 by jwe]
jwe
parents: 2475
diff changeset
534
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
535 pid_t pid = octave_syscalls::fork (msg);
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
536
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
537 retval(1) = msg;
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
538 retval(0) = pid;
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
539
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
540 return retval;
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
541 }
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
542
10299
c992efc0c2fa use DEFUNX instead of DEFUN for all functions in syscalls.cc
John W. Eaton <jwe@octave.org>
parents: 10259
diff changeset
543 DEFUNX ("getpgrp", Fgetpgrp, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
544 "-*- 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
545 @deftypefn {} {pgid =} getpgrp ()\n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
546 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
547 @end deftypefn")
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
548 {
2937
9d26524e2869 [project @ 1997-05-06 05:49:53 by jwe]
jwe
parents: 2926
diff changeset
549 octave_value_list retval;
9d26524e2869 [project @ 1997-05-06 05:49:53 by jwe]
jwe
parents: 2926
diff changeset
550
3523
b80bbb43a1a9 [project @ 2000-02-02 10:25:52 by jwe]
jwe
parents: 3458
diff changeset
551 retval(1) = std::string ();
4294
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4254
diff changeset
552 retval(0) = -1;
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
553
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
554 int nargin = args.length ();
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
555
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
556 if (nargin != 0)
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
557 print_usage ();
2937
9d26524e2869 [project @ 1997-05-06 05:49:53 by jwe]
jwe
parents: 2926
diff changeset
558
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
559 std::string msg;
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
560
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
561 retval(1) = msg;
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
562 retval(0) = octave_syscalls::getpgrp (msg);
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
563
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
564 return retval;
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
565 }
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
566
10299
c992efc0c2fa use DEFUNX instead of DEFUN for all functions in syscalls.cc
John W. Eaton <jwe@octave.org>
parents: 10259
diff changeset
567 DEFUNX ("getpid", Fgetpid, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
568 "-*- 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
569 @deftypefn {} {pid =} getpid ()\n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
570 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
571 @seealso{getppid}\n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
572 @end deftypefn")
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
573 {
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
574 int nargin = args.length ();
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
575
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
576 if (nargin != 0)
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5775
diff changeset
577 print_usage ();
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
578
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
579 return octave_value (octave_syscalls::getpid ());
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
580 }
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
581
10299
c992efc0c2fa use DEFUNX instead of DEFUN for all functions in syscalls.cc
John W. Eaton <jwe@octave.org>
parents: 10259
diff changeset
582 DEFUNX ("getppid", Fgetppid, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
583 "-*- 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
584 @deftypefn {} {pid =} getppid ()\n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
585 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
586 @seealso{getpid}\n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
587 @end deftypefn")
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
588 {
2475
1d7925d6bede [project @ 1996-11-07 04:36:00 by jwe]
jwe
parents: 2473
diff changeset
589 int nargin = args.length ();
1d7925d6bede [project @ 1996-11-07 04:36:00 by jwe]
jwe
parents: 2473
diff changeset
590
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
591 if (nargin != 0)
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5775
diff changeset
592 print_usage ();
2475
1d7925d6bede [project @ 1996-11-07 04:36:00 by jwe]
jwe
parents: 2473
diff changeset
593
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
594 return octave_value (octave_syscalls::getppid ());
2475
1d7925d6bede [project @ 1996-11-07 04:36:00 by jwe]
jwe
parents: 2473
diff changeset
595 }
1d7925d6bede [project @ 1996-11-07 04:36:00 by jwe]
jwe
parents: 2473
diff changeset
596
10299
c992efc0c2fa use DEFUNX instead of DEFUN for all functions in syscalls.cc
John W. Eaton <jwe@octave.org>
parents: 10259
diff changeset
597 DEFUNX ("getegid", Fgetegid, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
598 "-*- 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
599 @deftypefn {} {egid =} getegid ()\n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
600 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
601 @seealso{getgid}\n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
602 @end deftypefn")
2475
1d7925d6bede [project @ 1996-11-07 04:36:00 by jwe]
jwe
parents: 2473
diff changeset
603 {
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
604 int nargin = args.length ();
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
605
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
606 if (nargin != 0)
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5775
diff changeset
607 print_usage ();
2475
1d7925d6bede [project @ 1996-11-07 04:36:00 by jwe]
jwe
parents: 2473
diff changeset
608
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
609 return octave_value (octave_syscalls::getegid ());
2475
1d7925d6bede [project @ 1996-11-07 04:36:00 by jwe]
jwe
parents: 2473
diff changeset
610 }
1d7925d6bede [project @ 1996-11-07 04:36:00 by jwe]
jwe
parents: 2473
diff changeset
611
10299
c992efc0c2fa use DEFUNX instead of DEFUN for all functions in syscalls.cc
John W. Eaton <jwe@octave.org>
parents: 10259
diff changeset
612 DEFUNX ("getgid", Fgetgid, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
613 "-*- 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
614 @deftypefn {} {gid =} getgid ()\n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
615 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
616 @seealso{getegid}\n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
617 @end deftypefn")
2475
1d7925d6bede [project @ 1996-11-07 04:36:00 by jwe]
jwe
parents: 2473
diff changeset
618 {
1d7925d6bede [project @ 1996-11-07 04:36:00 by jwe]
jwe
parents: 2473
diff changeset
619 int nargin = args.length ();
1d7925d6bede [project @ 1996-11-07 04:36:00 by jwe]
jwe
parents: 2473
diff changeset
620
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
621 if (nargin != 0)
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5775
diff changeset
622 print_usage ();
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
623
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
624 return octave_value (octave_syscalls::getgid ());
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
625 }
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
626
10299
c992efc0c2fa use DEFUNX instead of DEFUN for all functions in syscalls.cc
John W. Eaton <jwe@octave.org>
parents: 10259
diff changeset
627 DEFUNX ("geteuid", Fgeteuid, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
628 "-*- 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
629 @deftypefn {} {euid =} geteuid ()\n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
630 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
631 @seealso{getuid}\n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
632 @end deftypefn")
2472
0c788e9b53b8 [project @ 1996-11-06 04:10:07 by jwe]
jwe
parents: 2457
diff changeset
633 {
4233
ccfdb55c8156 [project @ 2002-12-20 22:43:54 by jwe]
jwe
parents: 3887
diff changeset
634 octave_value retval = -1;
2472
0c788e9b53b8 [project @ 1996-11-06 04:10:07 by jwe]
jwe
parents: 2457
diff changeset
635
0c788e9b53b8 [project @ 1996-11-06 04:10:07 by jwe]
jwe
parents: 2457
diff changeset
636 int nargin = args.length ();
0c788e9b53b8 [project @ 1996-11-06 04:10:07 by jwe]
jwe
parents: 2457
diff changeset
637
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
638 if (nargin != 0)
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5775
diff changeset
639 print_usage ();
2473
bb0c213e5885 [project @ 1996-11-06 04:34:55 by jwe]
jwe
parents: 2472
diff changeset
640
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
641 retval = octave_syscalls::geteuid ();
2473
bb0c213e5885 [project @ 1996-11-06 04:34:55 by jwe]
jwe
parents: 2472
diff changeset
642 return retval;
2472
0c788e9b53b8 [project @ 1996-11-06 04:10:07 by jwe]
jwe
parents: 2457
diff changeset
643 }
0c788e9b53b8 [project @ 1996-11-06 04:10:07 by jwe]
jwe
parents: 2457
diff changeset
644
10299
c992efc0c2fa use DEFUNX instead of DEFUN for all functions in syscalls.cc
John W. Eaton <jwe@octave.org>
parents: 10259
diff changeset
645 DEFUNX ("getuid", Fgetuid, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
646 "-*- 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
647 @deftypefn {} {uid =} getuid ()\n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
648 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
649 @seealso{geteuid}\n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
650 @end deftypefn")
2472
0c788e9b53b8 [project @ 1996-11-06 04:10:07 by jwe]
jwe
parents: 2457
diff changeset
651 {
4233
ccfdb55c8156 [project @ 2002-12-20 22:43:54 by jwe]
jwe
parents: 3887
diff changeset
652 octave_value retval = -1;
2472
0c788e9b53b8 [project @ 1996-11-06 04:10:07 by jwe]
jwe
parents: 2457
diff changeset
653
0c788e9b53b8 [project @ 1996-11-06 04:10:07 by jwe]
jwe
parents: 2457
diff changeset
654 int nargin = args.length ();
0c788e9b53b8 [project @ 1996-11-06 04:10:07 by jwe]
jwe
parents: 2457
diff changeset
655
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
656 if (nargin != 0)
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5775
diff changeset
657 print_usage ();
2473
bb0c213e5885 [project @ 1996-11-06 04:34:55 by jwe]
jwe
parents: 2472
diff changeset
658
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
659 retval = octave_syscalls::getuid ();
2473
bb0c213e5885 [project @ 1996-11-06 04:34:55 by jwe]
jwe
parents: 2472
diff changeset
660 return retval;
2472
0c788e9b53b8 [project @ 1996-11-06 04:10:07 by jwe]
jwe
parents: 2457
diff changeset
661 }
0c788e9b53b8 [project @ 1996-11-06 04:10:07 by jwe]
jwe
parents: 2457
diff changeset
662
10299
c992efc0c2fa use DEFUNX instead of DEFUN for all functions in syscalls.cc
John W. Eaton <jwe@octave.org>
parents: 10259
diff changeset
663 DEFUNX ("kill", Fkill, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
664 "-*- 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
665 @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
666 Send signal @var{sig} to process @var{pid}.\n\
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4254
diff changeset
667 \n\
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4254
diff changeset
668 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
669 \n\
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4254
diff changeset
670 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
671 in the process group of the current process.\n\
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4254
diff changeset
672 \n\
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4254
diff changeset
673 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
674 except process 1.\n\
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4254
diff changeset
675 \n\
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4254
diff changeset
676 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
677 process in the process group @var{-pid}.\n\
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4254
diff changeset
678 \n\
4371
c14ec945fabb [project @ 2003-03-26 16:05:59 by jwe]
jwe
parents: 4327
diff changeset
679 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
680 performed.\n\
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4254
diff changeset
681 \n\
7001
8b0cfeb06365 [project @ 2007-10-10 18:02:59 by jwe]
jwe
parents: 6923
diff changeset
682 Return 0 if successful, otherwise return -1.\n\
4294
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4254
diff changeset
683 @end deftypefn")
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4254
diff changeset
684 {
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4254
diff changeset
685 octave_value_list retval;
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4254
diff changeset
686
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4254
diff changeset
687 retval(1) = std::string ();
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4254
diff changeset
688 retval(0) = -1;
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4254
diff changeset
689
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
690 if (args.length () != 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
691 print_usage ();
4294
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4254
diff changeset
692
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
693 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
694
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
695 int sig = args(1).int_value (true);
4294
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4254
diff changeset
696
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
697 std::string msg;
4294
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4254
diff changeset
698
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
699 int status = octave_syscalls::kill (pid, sig, 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
700
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
701 retval(1) = 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
702 retval(0) = status;
4294
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4254
diff changeset
703
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4254
diff changeset
704 return retval;
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4254
diff changeset
705 }
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4254
diff changeset
706
10299
c992efc0c2fa use DEFUNX instead of DEFUN for all functions in syscalls.cc
John W. Eaton <jwe@octave.org>
parents: 10259
diff changeset
707 DEFUNX ("lstat", Flstat, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
708 "-*- 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
709 @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
710 @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
711 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
712 @var{symlink}.\n\
0bf2fc8562c9 doc: Update documentation for file and directory functions.
Rik <rik@octave.org>
parents: 17281
diff changeset
713 \n\
0bf2fc8562c9 doc: Update documentation for file and directory functions.
Rik <rik@octave.org>
parents: 17281
diff changeset
714 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
715 @seealso{stat, symlink}\n\
3458
d25bc039237b [project @ 2000-01-19 09:36:14 by jwe]
jwe
parents: 3446
diff changeset
716 @end deftypefn")
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
717 {
2263
dafbde8087e6 [project @ 1996-05-23 18:44:40 by jwe]
jwe
parents: 2262
diff changeset
718 octave_value_list retval;
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
719
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
720 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
721 print_usage ();
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
722
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
723 std::string fname = args(0).xstring_value ("lstat: NAME must be a string");
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
724
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
725 file_stat fs (fname, false);
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
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
727 retval = mk_stat_result (fs);
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
728
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
729 return retval;
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
730 }
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
731
20200
d9f35ceff9e1 Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents: 20198
diff changeset
732 // 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
733 // 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
734 static int
d9f35ceff9e1 Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents: 20198
diff changeset
735 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
736 {
d9f35ceff9e1 Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents: 20198
diff changeset
737 int retval = 0;
d9f35ceff9e1 Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents: 20198
diff changeset
738
d9f35ceff9e1 Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents: 20198
diff changeset
739 int tmp = x % obase;
d9f35ceff9e1 Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents: 20198
diff changeset
740
d9f35ceff9e1 Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents: 20198
diff changeset
741 if (tmp > ibase - 1)
20428
7ac907da9fba Use error() rather than ::error() unless explicitly required.
Rik <rik@octave.org>
parents: 20232
diff changeset
742 error ("mkfifo: invalid digit");
20200
d9f35ceff9e1 Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents: 20198
diff changeset
743 else
d9f35ceff9e1 Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents: 20198
diff changeset
744 {
d9f35ceff9e1 Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents: 20198
diff changeset
745 retval = tmp;
d9f35ceff9e1 Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents: 20198
diff changeset
746 int mult = ibase;
d9f35ceff9e1 Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents: 20198
diff changeset
747 while ((x = (x - tmp) / obase))
d9f35ceff9e1 Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents: 20198
diff changeset
748 {
d9f35ceff9e1 Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents: 20198
diff changeset
749 tmp = x % obase;
d9f35ceff9e1 Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents: 20198
diff changeset
750 if (tmp > ibase - 1)
d9f35ceff9e1 Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents: 20198
diff changeset
751 {
20428
7ac907da9fba Use error() rather than ::error() unless explicitly required.
Rik <rik@octave.org>
parents: 20232
diff changeset
752 error ("mkfifo: invalid digit");
20200
d9f35ceff9e1 Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents: 20198
diff changeset
753 break;
d9f35ceff9e1 Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents: 20198
diff changeset
754 }
d9f35ceff9e1 Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents: 20198
diff changeset
755 retval += mult * tmp;
d9f35ceff9e1 Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents: 20198
diff changeset
756 mult *= ibase;
d9f35ceff9e1 Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents: 20198
diff changeset
757 }
d9f35ceff9e1 Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents: 20198
diff changeset
758 }
d9f35ceff9e1 Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents: 20198
diff changeset
759
d9f35ceff9e1 Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents: 20198
diff changeset
760 return retval;
d9f35ceff9e1 Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents: 20198
diff changeset
761 }
d9f35ceff9e1 Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents: 20198
diff changeset
762
10197
4d433bd2d4dc attempt to avoid trouble with gnulib #defines in a consistent way
John W. Eaton <jwe@octave.org>
parents: 10182
diff changeset
763 DEFUNX ("mkfifo", Fmkfifo, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
764 "-*- 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
765 @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
766 @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
767 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
768 \n\
20200
d9f35ceff9e1 Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents: 20198
diff changeset
769 @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
770 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
771 \n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
772 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
773 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
774 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
775 @seealso{pipe, umask}\n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
776 @end deftypefn")
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
777 {
20200
d9f35ceff9e1 Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents: 20198
diff changeset
778 octave_value_list retval (2);
2669
c821858188b6 [project @ 1997-02-13 18:25:39 by jwe]
jwe
parents: 2475
diff changeset
779
3523
b80bbb43a1a9 [project @ 2000-02-02 10:25:52 by jwe]
jwe
parents: 3458
diff changeset
780 retval(1) = std::string ();
4294
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4254
diff changeset
781 retval(0) = -1;
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
782
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
783 int nargin = args.length ();
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
784
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
785 if (nargin != 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
786 print_usage ();
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
787
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
788 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
789
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
790 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
791
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
792 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
793 error ("mkfifo: MODE must be a positive integer 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
794 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
795 {
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
796 int mode = convert (octal_mode, 8, 10);
20581
fd0efcdb3718 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20560
diff changeset
797
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
798 std::string msg;
20704
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20700
diff changeset
799
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
800 int status = octave_mkfifo (name, mode, 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
801
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
802 retval(0) = status;
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
803
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
804 if (status < 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
805 retval(1) = msg;
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
806 }
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
807
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
808
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
809 return retval;
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
810 }
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
811
20200
d9f35ceff9e1 Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents: 20198
diff changeset
812 /*
d9f35ceff9e1 Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents: 20198
diff changeset
813
d9f35ceff9e1 Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents: 20198
diff changeset
814 ## Test input validation
d9f35ceff9e1 Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents: 20198
diff changeset
815 %!error mkfifo ()
d9f35ceff9e1 Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents: 20198
diff changeset
816 %!error mkfifo ("abc")
d9f35ceff9e1 Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents: 20198
diff changeset
817 %!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
818 %!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
819 ## 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
820 #%!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
821 #%!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
822
d9f35ceff9e1 Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents: 20198
diff changeset
823 */
d9f35ceff9e1 Change mkfifo to use an octal argument for MODE (bug #45054).
Rik <rik@octave.org>
parents: 20198
diff changeset
824
10299
c992efc0c2fa use DEFUNX instead of DEFUN for all functions in syscalls.cc
John W. Eaton <jwe@octave.org>
parents: 10259
diff changeset
825 DEFUNX ("pipe", Fpipe, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
826 "-*- 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
827 @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
828 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
829 @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
830 \n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
831 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
832 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
833 error message.\n\
17397
0bf2fc8562c9 doc: Update documentation for file and directory functions.
Rik <rik@octave.org>
parents: 17281
diff changeset
834 @seealso{mkfifo}\n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
835 @end deftypefn")
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
836 {
2669
c821858188b6 [project @ 1997-02-13 18:25:39 by jwe]
jwe
parents: 2475
diff changeset
837 octave_value_list retval;
c821858188b6 [project @ 1997-02-13 18:25:39 by jwe]
jwe
parents: 2475
diff changeset
838
6321
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 5872
diff changeset
839 retval(3) = std::string ();
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 5872
diff changeset
840 retval(2) = -1;
4294
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4254
diff changeset
841 retval(1) = -1;
6321
363a2f8c9e97 [project @ 2007-02-16 20:26:23 by dbateman]
dbateman
parents: 5872
diff changeset
842 retval(0) = -1;
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
843
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
844 int nargin = args.length ();
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
845
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
846 if (nargin != 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
847 print_usage ();
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
848
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
849 int fid[2];
2937
9d26524e2869 [project @ 1997-05-06 05:49:53 by jwe]
jwe
parents: 2926
diff changeset
850
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
851 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
852
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
853 int status = octave_syscalls::pipe (fid, msg);
2669
c821858188b6 [project @ 1997-02-13 18:25:39 by jwe]
jwe
parents: 2475
diff changeset
854
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
855 if (status < 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
856 retval(3) = 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
857 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
858 {
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
859 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
860 FILE *ofile = fdopen (fid[1], "w");
4327
c29c382a5b4b [project @ 2003-02-16 03:24:26 by jwe]
jwe
parents: 4294
diff changeset
861
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
862 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
863 std::ios::in);
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
864
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
865 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
866 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
867
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
868 retval(2) = status;
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
869 retval(1) = octave_stream_list::insert (os);
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
870 retval(0) = octave_stream_list::insert (is);
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
871 }
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
872
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
873 return retval;
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
874 }
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
875
10299
c992efc0c2fa use DEFUNX instead of DEFUN for all functions in syscalls.cc
John W. Eaton <jwe@octave.org>
parents: 10259
diff changeset
876 DEFUNX ("stat", Fstat, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
877 "-*- 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
878 @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
879 @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
880 @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
881 @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
882 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
883 @var{file} or file identifier @var{fid}.\n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
884 \n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
885 @table @code\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
886 @item dev\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
887 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
888 \n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
889 @item ino\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
890 File number of the file.\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
891 \n\
5476
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
892 @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
893 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
894 @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
895 @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
896 information from this value.\n\
5476
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
897 \n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
898 @item modestr\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
899 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
900 @kbd{ls -l}.\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
901 \n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
902 @item nlink\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
903 Number of links.\n\
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
904 \n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
905 @item uid\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
906 User ID of file's owner.\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
907 \n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
908 @item gid\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
909 Group ID of file's group.\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
910 \n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
911 @item rdev\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
912 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
913 \n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
914 @item size\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
915 Size in bytes.\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
916 \n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
917 @item atime\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
918 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
919 @code{time}. @xref{Timing Utilities}.\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
920 \n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
921 @item mtime\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
922 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
923 @code{time}. @xref{Timing Utilities}.\n\
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
924 \n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
925 @item ctime\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
926 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
927 returned from @code{time}. @xref{Timing Utilities}.\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
928 \n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
929 @item blksize\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
930 Size of blocks in the file.\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
931 \n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
932 @item blocks\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
933 Number of blocks allocated for file.\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
934 @end table\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
935 \n\
20172
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
936 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
937 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
938 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
939 corresponding system error message.\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
940 \n\
20172
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
941 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
942 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
943 want information about the symbolic link itself.\n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
944 \n\
10840
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10791
diff changeset
945 For example:\n\
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
946 \n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
947 @example\n\
15065
f7215831fe78 doc: be consistent on var name on stat help text
Carnë Draug <carandraug+dev@gmail.com>
parents: 14861
diff changeset
948 [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
949 @result{} info =\n\
14360
97883071e8e4 doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents: 14171
diff changeset
950 @{\n\
97883071e8e4 doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents: 14171
diff changeset
951 atime = 855399756\n\
97883071e8e4 doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents: 14171
diff changeset
952 rdev = 0\n\
97883071e8e4 doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents: 14171
diff changeset
953 ctime = 847219094\n\
97883071e8e4 doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents: 14171
diff changeset
954 uid = 0\n\
97883071e8e4 doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents: 14171
diff changeset
955 size = 389218\n\
97883071e8e4 doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents: 14171
diff changeset
956 blksize = 4096\n\
97883071e8e4 doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents: 14171
diff changeset
957 mtime = 847219094\n\
97883071e8e4 doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents: 14171
diff changeset
958 gid = 6\n\
97883071e8e4 doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents: 14171
diff changeset
959 nlink = 1\n\
97883071e8e4 doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents: 14171
diff changeset
960 blocks = 768\n\
97883071e8e4 doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents: 14171
diff changeset
961 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
962 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
963 ino = 9316\n\
97883071e8e4 doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents: 14171
diff changeset
964 dev = 2049\n\
97883071e8e4 doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents: 14171
diff changeset
965 @}\n\
97883071e8e4 doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents: 14171
diff changeset
966 @result{} err = 0\n\
97883071e8e4 doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents: 14171
diff changeset
967 @result{} msg =\n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
968 @end example\n\
17397
0bf2fc8562c9 doc: Update documentation for file and directory functions.
Rik <rik@octave.org>
parents: 17281
diff changeset
969 @seealso{lstat, ls, dir}\n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
970 @end deftypefn")
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
971 {
2262
1300df4a33d6 [project @ 1996-05-23 06:49:32 by jwe]
jwe
parents: 2086
diff changeset
972 octave_value_list retval;
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
973
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
974 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
975 print_usage ();
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
976
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
977 if (args(0).is_scalar_type ())
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
978 {
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
979 int fid = octave_stream_list::get_file_number (args(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
980
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
981 file_fstat fs (fid);
10336
1603dfe72933 obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
982
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
983 retval = mk_stat_result (fs);
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
984 }
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 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
986 {
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
987 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
988
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
989 file_stat fs (fname);
10336
1603dfe72933 obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
990
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
991 retval = mk_stat_result (fs);
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
992 }
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
993
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
994 return retval;
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
995 }
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
996
5476
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
997 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
998 "-*- 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
999 @deftypefn {} {} S_ISREG (@var{mode})\n\
17397
0bf2fc8562c9 doc: Update documentation for file and directory functions.
Rik <rik@octave.org>
parents: 17281
diff changeset
1000 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
1001 \n\
0bf2fc8562c9 doc: Update documentation for file and directory functions.
Rik <rik@octave.org>
parents: 17281
diff changeset
1002 The value of @var{mode} is assumed to be returned from a call to @code{stat}.\n\
5476
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
1003 @seealso{stat, lstat}\n\
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
1004 @end deftypefn")
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
1005 {
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
1006 octave_value retval = false;
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
1007
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
1008 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
1009 print_usage ();
5476
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
1010
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
1011 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
1012
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1013 retval = 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
1014
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
1015 return retval;
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
1016 }
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
1017
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
1018 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
1019 "-*- 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
1020 @deftypefn {} {} S_ISDIR (@var{mode})\n\
17397
0bf2fc8562c9 doc: Update documentation for file and directory functions.
Rik <rik@octave.org>
parents: 17281
diff changeset
1021 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
1022 \n\
0bf2fc8562c9 doc: Update documentation for file and directory functions.
Rik <rik@octave.org>
parents: 17281
diff changeset
1023 The value of @var{mode} is assumed to be returned from a call to @code{stat}.\n\
5476
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
1024 @seealso{stat, lstat}\n\
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
1025 @end deftypefn")
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
1026 {
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
1027 octave_value retval = false;
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
1028
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
1029 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
1030 print_usage ();
5476
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
1031
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
1032 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
1033
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 retval = 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
1035
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
1036 return retval;
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
1037 }
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
1038
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
1039 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
1040 "-*- 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
1041 @deftypefn {} {} S_ISCHR (@var{mode})\n\
17397
0bf2fc8562c9 doc: Update documentation for file and directory functions.
Rik <rik@octave.org>
parents: 17281
diff changeset
1042 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
1043 \n\
0bf2fc8562c9 doc: Update documentation for file and directory functions.
Rik <rik@octave.org>
parents: 17281
diff changeset
1044 The value of @var{mode} is assumed to be returned from a call to @code{stat}.\n\
5476
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
1045 @seealso{stat, lstat}\n\
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
1046 @end deftypefn")
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
1047 {
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
1048 octave_value retval = false;
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
1049
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
1050 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
1051 print_usage ();
5476
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
1052
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
1053 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
1054
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1055 retval = file_stat::is_chr (static_cast<mode_t> (mode));
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1056
5476
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
1057
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
1058 return retval;
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
1059 }
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
1060
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
1061 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
1062 "-*- 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
1063 @deftypefn {} {} S_ISBLK (@var{mode})\n\
17397
0bf2fc8562c9 doc: Update documentation for file and directory functions.
Rik <rik@octave.org>
parents: 17281
diff changeset
1064 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
1065 \n\
0bf2fc8562c9 doc: Update documentation for file and directory functions.
Rik <rik@octave.org>
parents: 17281
diff changeset
1066 The value of @var{mode} is assumed to be returned from a call to @code{stat}.\n\
5476
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
1067 @seealso{stat, lstat}\n\
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
1068 @end deftypefn")
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
1069 {
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
1070 octave_value retval = false;
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
1071
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
1072 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
1073 print_usage ();
5476
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
1074
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
1075 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
1076
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1077 retval = 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
1078
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
1079 return retval;
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
1080 }
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
1081
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
1082 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
1083 "-*- 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
1084 @deftypefn {} {} S_ISFIFO (@var{mode})\n\
17397
0bf2fc8562c9 doc: Update documentation for file and directory functions.
Rik <rik@octave.org>
parents: 17281
diff changeset
1085 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
1086 \n\
0bf2fc8562c9 doc: Update documentation for file and directory functions.
Rik <rik@octave.org>
parents: 17281
diff changeset
1087 The value of @var{mode} is assumed to be returned from a call to @code{stat}.\n\
5476
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
1088 @seealso{stat, lstat}\n\
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
1089 @end deftypefn")
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
1090 {
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
1091 octave_value retval = false;
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
1092
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
1093 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
1094 print_usage ();
5476
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
1095
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
1096 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
1097
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1098 retval = 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
1099
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
1100 return retval;
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
1101 }
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
1102
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
1103 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
1104 "-*- 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
1105 @deftypefn {} {} S_ISLNK (@var{mode})\n\
17397
0bf2fc8562c9 doc: Update documentation for file and directory functions.
Rik <rik@octave.org>
parents: 17281
diff changeset
1106 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
1107 \n\
0bf2fc8562c9 doc: Update documentation for file and directory functions.
Rik <rik@octave.org>
parents: 17281
diff changeset
1108 The value of @var{mode} is assumed to be returned from a call to @code{stat}.\n\
5476
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
1109 @seealso{stat, lstat}\n\
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
1110 @end deftypefn")
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
1111 {
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
1112 octave_value retval = false;
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
1113
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
1114 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
1115 print_usage ();
5476
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
1116
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
1117 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
1118
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1119 retval = 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
1120
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
1121 return retval;
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
1122 }
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
1123
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
1124 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
1125 "-*- 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
1126 @deftypefn {} {} S_ISSOCK (@var{mode})\n\
17397
0bf2fc8562c9 doc: Update documentation for file and directory functions.
Rik <rik@octave.org>
parents: 17281
diff changeset
1127 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
1128 \n\
0bf2fc8562c9 doc: Update documentation for file and directory functions.
Rik <rik@octave.org>
parents: 17281
diff changeset
1129 The value of @var{mode} is assumed to be returned from a call to @code{stat}.\n\
5476
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
1130 @seealso{stat, lstat}\n\
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
1131 @end deftypefn")
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
1132 {
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
1133 octave_value retval = false;
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
1134
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
1135 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
1136 print_usage ();
5476
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
1137
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
1138 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
1139
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1140 retval = file_stat::is_sock (static_cast<mode_t> (mode));
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1141
5476
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
1142
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
1143 return retval;
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
1144 }
941f0fc6b596 [project @ 2005-09-29 22:46:07 by jwe]
jwe
parents: 5455
diff changeset
1145
11006
aca961a3f387 provide gethostname function
John W. Eaton <jwe@octave.org>
parents: 10840
diff changeset
1146 DEFUN (gethostname, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1147 "-*- 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
1148 @deftypefn {} {} gethostname ()\n\
12514
e5e66c389597 Add gethostname to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12483
diff changeset
1149 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
1150 @end deftypefn")
aca961a3f387 provide gethostname function
John W. Eaton <jwe@octave.org>
parents: 10840
diff changeset
1151 {
aca961a3f387 provide gethostname function
John W. Eaton <jwe@octave.org>
parents: 10840
diff changeset
1152 octave_value retval;
aca961a3f387 provide gethostname function
John W. Eaton <jwe@octave.org>
parents: 10840
diff changeset
1153
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
1154 if (args.length () != 0)
11006
aca961a3f387 provide gethostname function
John W. Eaton <jwe@octave.org>
parents: 10840
diff changeset
1155 print_usage ();
aca961a3f387 provide gethostname function
John W. Eaton <jwe@octave.org>
parents: 10840
diff changeset
1156
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
1157 retval = octave_env::get_host_name ();
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1158
11006
aca961a3f387 provide gethostname function
John W. Eaton <jwe@octave.org>
parents: 10840
diff changeset
1159 return retval;
aca961a3f387 provide gethostname function
John W. Eaton <jwe@octave.org>
parents: 10840
diff changeset
1160 }
aca961a3f387 provide gethostname function
John W. Eaton <jwe@octave.org>
parents: 10840
diff changeset
1161
5547
8b0b36c2dc0c [project @ 2005-11-29 17:41:33 by jwe]
jwe
parents: 5476
diff changeset
1162 DEFUN (uname, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1163 "-*- 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
1164 @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
1165 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
1166 \n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
1167 For example:\n\
5547
8b0b36c2dc0c [project @ 2005-11-29 17:41:33 by jwe]
jwe
parents: 5476
diff changeset
1168 \n\
8b0b36c2dc0c [project @ 2005-11-29 17:41:33 by jwe]
jwe
parents: 5476
diff changeset
1169 @example\n\
8b0b36c2dc0c [project @ 2005-11-29 17:41:33 by jwe]
jwe
parents: 5476
diff changeset
1170 @group\n\
8b0b36c2dc0c [project @ 2005-11-29 17:41:33 by jwe]
jwe
parents: 5476
diff changeset
1171 uname ()\n\
14360
97883071e8e4 doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents: 14171
diff changeset
1172 @result{} @{\n\
97883071e8e4 doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents: 14171
diff changeset
1173 sysname = x86_64\n\
97883071e8e4 doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents: 14171
diff changeset
1174 nodename = segfault\n\
97883071e8e4 doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents: 14171
diff changeset
1175 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
1176 version = Linux\n\
97883071e8e4 doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents: 14171
diff changeset
1177 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
1178 @}\n\
5547
8b0b36c2dc0c [project @ 2005-11-29 17:41:33 by jwe]
jwe
parents: 5476
diff changeset
1179 @end group\n\
8b0b36c2dc0c [project @ 2005-11-29 17:41:33 by jwe]
jwe
parents: 5476
diff changeset
1180 @end example\n\
8b0b36c2dc0c [project @ 2005-11-29 17:41:33 by jwe]
jwe
parents: 5476
diff changeset
1181 \n\
8b0b36c2dc0c [project @ 2005-11-29 17:41:33 by jwe]
jwe
parents: 5476
diff changeset
1182 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
1183 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
1184 system-dependent error message.\n\
8b0b36c2dc0c [project @ 2005-11-29 17:41:33 by jwe]
jwe
parents: 5476
diff changeset
1185 @end deftypefn")
8b0b36c2dc0c [project @ 2005-11-29 17:41:33 by jwe]
jwe
parents: 5476
diff changeset
1186 {
8b0b36c2dc0c [project @ 2005-11-29 17:41:33 by jwe]
jwe
parents: 5476
diff changeset
1187 octave_value_list retval;
8b0b36c2dc0c [project @ 2005-11-29 17:41:33 by jwe]
jwe
parents: 5476
diff changeset
1188
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
1189 if (args.length () != 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
1190 print_usage ();
5547
8b0b36c2dc0c [project @ 2005-11-29 17:41:33 by jwe]
jwe
parents: 5476
diff changeset
1191
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
1192 octave_uname sysinfo;
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1193
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1194 octave_scalar_map m;
5547
8b0b36c2dc0c [project @ 2005-11-29 17:41:33 by jwe]
jwe
parents: 5476
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 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
1197 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
1198 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
1199 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
1200 m.assign ("machine", sysinfo.machine ());
5547
8b0b36c2dc0c [project @ 2005-11-29 17:41:33 by jwe]
jwe
parents: 5476
diff changeset
1201
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
1202 retval(2) = sysinfo.message ();
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1203 retval(1) = sysinfo.error ();
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1204 retval(0) = m;
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1205
5547
8b0b36c2dc0c [project @ 2005-11-29 17:41:33 by jwe]
jwe
parents: 5476
diff changeset
1206
8b0b36c2dc0c [project @ 2005-11-29 17:41:33 by jwe]
jwe
parents: 5476
diff changeset
1207 return retval;
8b0b36c2dc0c [project @ 2005-11-29 17:41:33 by jwe]
jwe
parents: 5476
diff changeset
1208 }
8b0b36c2dc0c [project @ 2005-11-29 17:41:33 by jwe]
jwe
parents: 5476
diff changeset
1209
10197
4d433bd2d4dc attempt to avoid trouble with gnulib #defines in a consistent way
John W. Eaton <jwe@octave.org>
parents: 10182
diff changeset
1210 DEFUNX ("unlink", Funlink, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1211 "-*- 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
1212 @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
1213 Delete the file named @var{file}.\n\
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1214 \n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
1215 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
1216 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
1217 error message.\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
1218 @seealso{delete, rmdir}\n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
1219 @end deftypefn")
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1220 {
2669
c821858188b6 [project @ 1997-02-13 18:25:39 by jwe]
jwe
parents: 2475
diff changeset
1221 octave_value_list retval;
c821858188b6 [project @ 1997-02-13 18:25:39 by jwe]
jwe
parents: 2475
diff changeset
1222
3523
b80bbb43a1a9 [project @ 2000-02-02 10:25:52 by jwe]
jwe
parents: 3458
diff changeset
1223 retval(1) = std::string ();
4294
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4254
diff changeset
1224 retval(0) = -1;
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1225
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1226 int nargin = args.length ();
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1227
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
1228 if (nargin != 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
1229 print_usage ();
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1230
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
1231 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
1232
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
1233 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
1234
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 int status = octave_unlink (name, msg);
2669
c821858188b6 [project @ 1997-02-13 18:25:39 by jwe]
jwe
parents: 2475
diff changeset
1236
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
1237 retval(1) = 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
1238 retval(0) = status;
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1239
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1240
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1241 return retval;
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1242 }
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1243
10299
c992efc0c2fa use DEFUNX instead of DEFUN for all functions in syscalls.cc
John W. Eaton <jwe@octave.org>
parents: 10259
diff changeset
1244 DEFUNX ("waitpid", Fwaitpid, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1245 "-*- 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
1246 @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
1247 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
1248 \n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
1249 The @var{pid} argument can be:\n\
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1250 \n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
1251 @table @asis\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
1252 @item @minus{}1\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
1253 Wait for any child process.\n\
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1254 \n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
1255 @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
1256 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
1257 Octave interpreter process.\n\
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1258 \n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
1259 @item > 0\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
1260 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
1261 @end table\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
1262 \n\
20172
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
1263 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
1264 following constants:\n\
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1265 \n\
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1266 @table @code\n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
1267 @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
1268 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
1269 if the @var{options} argument is missing).\n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
1270 \n\
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1271 @item WNOHANG\n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
1272 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
1273 \n\
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1274 @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
1275 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
1276 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
1277 \n\
8286
6f2d95255911 fix @seealso references to point to existing anchors
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 7924
diff changeset
1278 @item WCONTINUE\n\
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1279 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
1280 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
1281 @end table\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3202
diff changeset
1282 \n\
20172
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
1283 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
1284 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
1285 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
1286 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
1287 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
1288 @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
1289 @end deftypefn")
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1290 {
2669
c821858188b6 [project @ 1997-02-13 18:25:39 by jwe]
jwe
parents: 2475
diff changeset
1291 octave_value_list retval;
c821858188b6 [project @ 1997-02-13 18:25:39 by jwe]
jwe
parents: 2475
diff changeset
1292
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1293 retval(2) = std::string ();
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1294 retval(1) = 0;
4294
755f6509bb01 [project @ 2003-01-11 04:01:53 by jwe]
jwe
parents: 4254
diff changeset
1295 retval(0) = -1;
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1296
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1297 int nargin = args.length ();
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1298
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
1299 if (nargin != 1 && nargin != 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
1300 print_usage ();
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1301
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1302 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
1303
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
1304 int options = 0;
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1305
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
1306 if (args.length () == 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
1307 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
1308
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
1309 std::string msg;
3202
44d82b369c78 [project @ 1998-10-29 20:27:57 by jwe]
jwe
parents: 3156
diff changeset
1310
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
1311 int status = 0;
20704
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20700
diff changeset
1312
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
1313 pid_t result = octave_syscalls::waitpid (pid, &status,
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1314 options, 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
1315
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1316 retval(2) = 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
1317 retval(1) = status;
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1318 retval(0) = result;
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1319
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1320 return retval;
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1321 }
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1322
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1323 DEFUNX ("WIFEXITED", FWIFEXITED, 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 {} {} 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
1326 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
1327 true if the child terminated normally.\n\
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1328 @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
1329 @end deftypefn")
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1330 {
15221
a83b7b2f95ee avoid C-style cast warnings from GCC for wait-related macros
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1331 octave_value retval = false;
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1332
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
1333 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
1334 print_usage ();
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1335
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
1336 int status = args(0).xint_value ("WIFEXITED: STATUS must be an integer");
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1337
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1338 retval = octave_wait::ifexited (status);
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1339
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1340 return retval;
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1341 }
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1342
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1343 DEFUNX ("WEXITSTATUS", FWEXITSTATUS, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1344 "-*- 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
1345 @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
1346 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
1347 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
1348 \n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
1349 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
1350 @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
1351 @end deftypefn")
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1352 {
15221
a83b7b2f95ee avoid C-style cast warnings from GCC for wait-related macros
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1353 octave_value retval = 0;
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1354
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1355 if (args.length () == 1)
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1356 {
20704
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20700
diff changeset
1357 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
1358
20704
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20700
diff changeset
1359 retval = octave_wait::exitstatus (status);
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1360 }
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1361
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1362 return retval;
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1363 }
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1364
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1365 DEFUNX ("WIFSIGNALED", FWIFSIGNALED, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1366 "-*- 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
1367 @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
1368 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
1369 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
1370 @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
1371 @end deftypefn")
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1372 {
15221
a83b7b2f95ee avoid C-style cast warnings from GCC for wait-related macros
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1373 octave_value retval = false;
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1374
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
1375 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
1376 print_usage ();
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1377
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
1378 int status = args(0).xint_value ("WIFSIGNALED: STATUS must be an integer");
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1379
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1380 retval = octave_wait::ifsignaled (status);
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1381
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1382
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1383 return retval;
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1384 }
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1385
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1386 DEFUNX ("WTERMSIG", FWTERMSIG, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1387 "-*- 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
1388 @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
1389 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
1390 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
1391 \n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
1392 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
1393 @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
1394 @end deftypefn")
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1395 {
15221
a83b7b2f95ee avoid C-style cast warnings from GCC for wait-related macros
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1396 octave_value retval = 0;
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1397
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
1398 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
1399 print_usage ();
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1400
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
1401 int status = args(0).xint_value ("WTERMSIG: STATUS must be an integer");
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1402
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1403 retval = octave_wait::termsig (status);
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1404
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1405
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1406 return retval;
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1407 }
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1408
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1409 DEFUNX ("WCOREDUMP", FWCOREDUMP, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1410 "-*- 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
1411 @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
1412 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
1413 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
1414 \n\
20181
aa36fb998a4d maint: Remove unnecessary whitespace at end of lines.
Rik <rik@octave.org>
parents: 20172
diff changeset
1415 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
1416 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
1417 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
1418 @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
1419 @end deftypefn")
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1420 {
15221
a83b7b2f95ee avoid C-style cast warnings from GCC for wait-related macros
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1421 octave_value retval = false;
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1422
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
1423 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
1424 print_usage ();
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1425
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
1426 int status = args(0).xint_value ("WCOREDUMP: STATUS must be an integer");
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1427
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1428 retval = octave_wait::coredump (status);
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1429
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1430
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1431 return retval;
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1432 }
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1433
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1434 DEFUNX ("WIFSTOPPED", FWIFSTOPPED, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1435 "-*- 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
1436 @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
1437 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
1438 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
1439 \n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
1440 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
1441 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
1442 @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
1443 @end deftypefn")
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1444 {
15221
a83b7b2f95ee avoid C-style cast warnings from GCC for wait-related macros
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1445 octave_value retval = false;
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1446
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
1447 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
1448 print_usage ();
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1449
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
1450 int status = args(0).xint_value ("WIFSTOPPED: STATUS must be an integer");
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1451
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1452 retval = octave_wait::ifstopped (status);
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1453
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1454
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1455 return retval;
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1456 }
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1457
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1458 DEFUNX ("WSTOPSIG", FWSTOPSIG, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1459 "-*- 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
1460 @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
1461 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
1462 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
1463 \n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
1464 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
1465 @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
1466 @end deftypefn")
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1467 {
15221
a83b7b2f95ee avoid C-style cast warnings from GCC for wait-related macros
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1468 octave_value retval = 0;
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1469
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
1470 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
1471 print_usage ();
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1472
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
1473 int status = args(0).xint_value ("WSTOPSIG: STATUS must be an integer");
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1474
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1475 retval = octave_wait::stopsig (status);
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1476
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1477
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1478 return retval;
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1479 }
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1480
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1481 DEFUNX ("WIFCONTINUED", FWIFCONTINUED, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1482 "-*- 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
1483 @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
1484 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
1485 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
1486 @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
1487 @end deftypefn")
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1488 {
15221
a83b7b2f95ee avoid C-style cast warnings from GCC for wait-related macros
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
1489 octave_value retval = false;
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1490
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
1491 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
1492 print_usage ();
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1493
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
1494 int status = args(0).xint_value ("WIFCONTINUED: STATUS must be an integer");
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1495
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1496 retval = octave_wait::ifcontinued (status);
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1497
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1498
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1499 return retval;
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1500 }
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1501
10249
14eba566f9f0 use DEFUNX instead of DEFUN for canonicalize_file_name
John W. Eaton <jwe@octave.org>
parents: 10197
diff changeset
1502 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
1503 "-*- 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
1504 @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
1505 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
1506 \n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
1507 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
1508 @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
1509 @end deftypefn")
5fa9670b5956 [project @ 2005-02-09 23:13:03 by jwe]
jwe
parents: 5040
diff changeset
1510 {
5fa9670b5956 [project @ 2005-02-09 23:13:03 by jwe]
jwe
parents: 5040
diff changeset
1511 octave_value_list retval;
5fa9670b5956 [project @ 2005-02-09 23:13:03 by jwe]
jwe
parents: 5040
diff changeset
1512
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
1513 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
1514 print_usage ();
5138
5fa9670b5956 [project @ 2005-02-09 23:13:03 by jwe]
jwe
parents: 5040
diff changeset
1515
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
1516 std::string name = args(0).xstring_value ("canonicalize_file_name: NAME 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
1517 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
1518
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
1519 std::string result = octave_canonicalize_file_name (name, 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
1520
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1521 retval(2) = 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
1522 retval(1) = msg.empty () ? 0 : -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
1523 retval(0) = result;
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1524
5138
5fa9670b5956 [project @ 2005-02-09 23:13:03 by jwe]
jwe
parents: 5040
diff changeset
1525
5fa9670b5956 [project @ 2005-02-09 23:13:03 by jwe]
jwe
parents: 5040
diff changeset
1526 return retval;
5fa9670b5956 [project @ 2005-02-09 23:13:03 by jwe]
jwe
parents: 5040
diff changeset
1527 }
5fa9670b5956 [project @ 2005-02-09 23:13:03 by jwe]
jwe
parents: 5040
diff changeset
1528
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1529 static octave_value
7924
4976f66d469b miscellaneous cleanup
John W. Eaton <jwe@octave.org>
parents: 7096
diff changeset
1530 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
1531 {
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1532 octave_value retval;
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1533
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1534 int nargin = args.length ();
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1535
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
1536 if (nargin != 0)
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5775
diff changeset
1537 print_usage ();
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1538
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
1539 retval = val;
b3a18c764161 Code sprint 2015: Refactor print_usage() in syscalls.cc to resemble m-files
Yu Liu <yul.liuiyu@gmail.com>
parents: 20853
diff changeset
1540
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1541 return retval;
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1542 }
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1543
20791
f7084eae3318 maint: Use Octave coding conventions for #if statements.
Rik <rik@octave.org>
parents: 20764
diff changeset
1544 #if ! defined (O_NONBLOCK) && defined (O_NDELAY)
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1545 #define O_NONBLOCK O_NDELAY
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1546 #endif
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1547
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1548 DEFUNX ("F_DUPFD", FF_DUPFD, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1549 "-*- 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
1550 @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
1551 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
1552 a duplicate file descriptor.\n\
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1553 @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
1554 @end deftypefn")
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1555 {
14111
c5222658dc3c doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents: 14022
diff changeset
1556 #if defined (F_DUPFD)
7924
4976f66d469b miscellaneous cleanup
John W. Eaton <jwe@octave.org>
parents: 7096
diff changeset
1557 return const_value (args, F_DUPFD);
14111
c5222658dc3c doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents: 14022
diff changeset
1558 #else
c5222658dc3c doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents: 14022
diff changeset
1559 error ("F_DUPFD: not available on this system");
c5222658dc3c doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents: 14022
diff changeset
1560 return octave_value ();
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1561 #endif
14111
c5222658dc3c doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents: 14022
diff changeset
1562 }
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1563
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1564 DEFUNX ("F_GETFD", FF_GETFD, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1565 "-*- 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
1566 @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
1567 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
1568 the file descriptor flags.\n\
5333
ac8d64b9e76a [project @ 2005-05-02 18:15:20 by jwe]
jwe
parents: 5307
diff changeset
1569 @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
1570 @end deftypefn")
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1571 {
14111
c5222658dc3c doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents: 14022
diff changeset
1572 #if defined (F_GETFD)
7924
4976f66d469b miscellaneous cleanup
John W. Eaton <jwe@octave.org>
parents: 7096
diff changeset
1573 return const_value (args, F_GETFD);
14111
c5222658dc3c doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents: 14022
diff changeset
1574 #else
c5222658dc3c doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents: 14022
diff changeset
1575 error ("F_GETFD: not available on this system");
c5222658dc3c doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents: 14022
diff changeset
1576 return octave_value ();
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1577 #endif
14111
c5222658dc3c doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents: 14022
diff changeset
1578 }
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1579
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1580 DEFUNX ("F_GETFL", FF_GETFL, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1581 "-*- 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
1582 @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
1583 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
1584 the file status flags.\n\
5333
ac8d64b9e76a [project @ 2005-05-02 18:15:20 by jwe]
jwe
parents: 5307
diff changeset
1585 @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
1586 @end deftypefn")
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1587 {
14111
c5222658dc3c doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents: 14022
diff changeset
1588 #if defined (F_GETFL)
7924
4976f66d469b miscellaneous cleanup
John W. Eaton <jwe@octave.org>
parents: 7096
diff changeset
1589 return const_value (args, F_GETFL);
14111
c5222658dc3c doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents: 14022
diff changeset
1590 #else
c5222658dc3c doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents: 14022
diff changeset
1591 error ("F_GETFL: not available on this system");
c5222658dc3c doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents: 14022
diff changeset
1592 return octave_value ();
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1593 #endif
14111
c5222658dc3c doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents: 14022
diff changeset
1594 }
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1595
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1596 DEFUNX ("F_SETFD", FF_SETFD, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1597 "-*- 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
1598 @deftypefn {} {} F_SETFD ()\n\
14171
2ced2f59f523 doc: miscellaneous documentation improvements
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
1599 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
1600 descriptor flags.\n\
5333
ac8d64b9e76a [project @ 2005-05-02 18:15:20 by jwe]
jwe
parents: 5307
diff changeset
1601 @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
1602 @end deftypefn")
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1603 {
14111
c5222658dc3c doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents: 14022
diff changeset
1604 #if defined (F_SETFD)
7924
4976f66d469b miscellaneous cleanup
John W. Eaton <jwe@octave.org>
parents: 7096
diff changeset
1605 return const_value (args, F_SETFD);
14111
c5222658dc3c doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents: 14022
diff changeset
1606 #else
c5222658dc3c doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents: 14022
diff changeset
1607 error ("F_SETFD: not available on this system");
c5222658dc3c doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents: 14022
diff changeset
1608 return octave_value ();
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1609 #endif
14111
c5222658dc3c doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents: 14022
diff changeset
1610 }
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1611
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1612 DEFUNX ("F_SETFL", FF_SETFL, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1613 "-*- 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
1614 @deftypefn {} {} F_SETFL ()\n\
14171
2ced2f59f523 doc: miscellaneous documentation improvements
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
1615 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
1616 status flags.\n\
5333
ac8d64b9e76a [project @ 2005-05-02 18:15:20 by jwe]
jwe
parents: 5307
diff changeset
1617 @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
1618 @end deftypefn")
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1619 {
14111
c5222658dc3c doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents: 14022
diff changeset
1620 #if defined (F_SETFL)
7924
4976f66d469b miscellaneous cleanup
John W. Eaton <jwe@octave.org>
parents: 7096
diff changeset
1621 return const_value (args, F_SETFL);
14111
c5222658dc3c doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents: 14022
diff changeset
1622 #else
c5222658dc3c doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents: 14022
diff changeset
1623 error ("F_SETFL: not available on this system");
c5222658dc3c doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents: 14022
diff changeset
1624 return octave_value ();
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1625 #endif
14111
c5222658dc3c doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents: 14022
diff changeset
1626 }
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1627
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1628 DEFUNX ("O_APPEND", FO_APPEND, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1629 "-*- 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
1630 @deftypefn {} {} O_APPEND ()\n\
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1631 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
1632 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
1633 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
1634 @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
1635 @end deftypefn")
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1636 {
14111
c5222658dc3c doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents: 14022
diff changeset
1637 #if defined (O_APPEND)
7924
4976f66d469b miscellaneous cleanup
John W. Eaton <jwe@octave.org>
parents: 7096
diff changeset
1638 return const_value (args, O_APPEND);
14111
c5222658dc3c doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents: 14022
diff changeset
1639 #else
c5222658dc3c doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents: 14022
diff changeset
1640 error ("O_APPEND: not available on this system");
c5222658dc3c doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents: 14022
diff changeset
1641 return octave_value ();
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1642 #endif
14111
c5222658dc3c doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents: 14022
diff changeset
1643 }
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1644
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1645 DEFUNX ("O_ASYNC", FO_ASYNC, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1646 "-*- 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
1647 @deftypefn {} {} O_ASYNC ()\n\
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1648 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
1649 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
1650 @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
1651 @end deftypefn")
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1652 {
14111
c5222658dc3c doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents: 14022
diff changeset
1653 #if defined (O_ASYNC)
7924
4976f66d469b miscellaneous cleanup
John W. Eaton <jwe@octave.org>
parents: 7096
diff changeset
1654 return const_value (args, O_ASYNC);
14111
c5222658dc3c doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents: 14022
diff changeset
1655 #else
c5222658dc3c doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents: 14022
diff changeset
1656 error ("O_ASYNC: not available on this system");
c5222658dc3c doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents: 14022
diff changeset
1657 return octave_value ();
2669
c821858188b6 [project @ 1997-02-13 18:25:39 by jwe]
jwe
parents: 2475
diff changeset
1658 #endif
14111
c5222658dc3c doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents: 14022
diff changeset
1659 }
2669
c821858188b6 [project @ 1997-02-13 18:25:39 by jwe]
jwe
parents: 2475
diff changeset
1660
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1661 DEFUNX ("O_CREAT", FO_CREAT, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1662 "-*- 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
1663 @deftypefn {} {} O_CREAT ()\n\
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1664 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
1665 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
1666 does not exist.\n\
5333
ac8d64b9e76a [project @ 2005-05-02 18:15:20 by jwe]
jwe
parents: 5307
diff changeset
1667 @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
1668 @end deftypefn")
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1669 {
14111
c5222658dc3c doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents: 14022
diff changeset
1670 #if defined (O_CREAT)
7924
4976f66d469b miscellaneous cleanup
John W. Eaton <jwe@octave.org>
parents: 7096
diff changeset
1671 return const_value (args, O_CREAT);
14111
c5222658dc3c doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents: 14022
diff changeset
1672 #else
c5222658dc3c doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents: 14022
diff changeset
1673 error ("O_CREAT: not available on this system");
c5222658dc3c doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents: 14022
diff changeset
1674 return octave_value ();
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1675 #endif
14111
c5222658dc3c doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents: 14022
diff changeset
1676 }
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1677
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1678 DEFUNX ("O_EXCL", FO_EXCL, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1679 "-*- 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
1680 @deftypefn {} {} O_EXCL ()\n\
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1681 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
1682 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
1683 @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
1684 @end deftypefn")
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1685 {
14111
c5222658dc3c doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents: 14022
diff changeset
1686 #if defined (O_EXCL)
7924
4976f66d469b miscellaneous cleanup
John W. Eaton <jwe@octave.org>
parents: 7096
diff changeset
1687 return const_value (args, O_EXCL);
14111
c5222658dc3c doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents: 14022
diff changeset
1688 #else
c5222658dc3c doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents: 14022
diff changeset
1689 error ("O_EXCL: not available on this system");
c5222658dc3c doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents: 14022
diff changeset
1690 return octave_value ();
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1691 #endif
14111
c5222658dc3c doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents: 14022
diff changeset
1692 }
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1693
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1694 DEFUNX ("O_NONBLOCK", FO_NONBLOCK, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1695 "-*- 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
1696 @deftypefn {} {} O_NONBLOCK ()\n\
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1697 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
1698 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
1699 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
1700 @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
1701 @end deftypefn")
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1702 {
14111
c5222658dc3c doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents: 14022
diff changeset
1703 #if defined (O_NONBLOCK)
7924
4976f66d469b miscellaneous cleanup
John W. Eaton <jwe@octave.org>
parents: 7096
diff changeset
1704 return const_value (args, O_NONBLOCK);
14111
c5222658dc3c doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents: 14022
diff changeset
1705 #else
c5222658dc3c doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents: 14022
diff changeset
1706 error ("O_NONBLOCK: not available on this system");
c5222658dc3c doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents: 14022
diff changeset
1707 return octave_value ();
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1708 #endif
14111
c5222658dc3c doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents: 14022
diff changeset
1709 }
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1710
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1711 DEFUNX ("O_RDONLY", FO_RDONLY, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1712 "-*- 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
1713 @deftypefn {} {} O_RDONLY ()\n\
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1714 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
1715 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
1716 @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
1717 @end deftypefn")
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1718 {
14111
c5222658dc3c doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents: 14022
diff changeset
1719 #if defined (O_RDONLY)
7924
4976f66d469b miscellaneous cleanup
John W. Eaton <jwe@octave.org>
parents: 7096
diff changeset
1720 return const_value (args, O_RDONLY);
14111
c5222658dc3c doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents: 14022
diff changeset
1721 #else
c5222658dc3c doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents: 14022
diff changeset
1722 error ("O_RDONLY: not available on this system");
c5222658dc3c doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents: 14022
diff changeset
1723 return octave_value ();
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1724 #endif
14111
c5222658dc3c doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents: 14022
diff changeset
1725 }
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1726
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1727 DEFUNX ("O_RDWR", FO_RDWR, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1728 "-*- 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
1729 @deftypefn {} {} O_RDWR ()\n\
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1730 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
1731 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
1732 and writing.\n\
5333
ac8d64b9e76a [project @ 2005-05-02 18:15:20 by jwe]
jwe
parents: 5307
diff changeset
1733 @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
1734 @end deftypefn")
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1735 {
14111
c5222658dc3c doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents: 14022
diff changeset
1736 #if defined (O_RDWR)
7924
4976f66d469b miscellaneous cleanup
John W. Eaton <jwe@octave.org>
parents: 7096
diff changeset
1737 return const_value (args, O_RDWR);
14111
c5222658dc3c doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents: 14022
diff changeset
1738 #else
c5222658dc3c doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents: 14022
diff changeset
1739 error ("O_RDWR: not available on this system");
c5222658dc3c doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents: 14022
diff changeset
1740 return octave_value ();
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1741 #endif
14111
c5222658dc3c doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents: 14022
diff changeset
1742 }
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1743
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1744 DEFUNX ("O_SYNC", FO_SYNC, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1745 "-*- 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
1746 @deftypefn {} {} O_SYNC ()\n\
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1747 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
1748 returned by @code{fcntl} to indicate that a file is open for synchronous I/O.\n\
5333
ac8d64b9e76a [project @ 2005-05-02 18:15:20 by jwe]
jwe
parents: 5307
diff changeset
1749 @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
1750 @end deftypefn")
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1751 {
14111
c5222658dc3c doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents: 14022
diff changeset
1752 #if defined (O_SYNC)
7924
4976f66d469b miscellaneous cleanup
John W. Eaton <jwe@octave.org>
parents: 7096
diff changeset
1753 return const_value (args, O_SYNC);
14111
c5222658dc3c doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents: 14022
diff changeset
1754 #else
c5222658dc3c doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents: 14022
diff changeset
1755 error ("O_SYNC: not available on this system");
c5222658dc3c doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents: 14022
diff changeset
1756 return octave_value ();
2669
c821858188b6 [project @ 1997-02-13 18:25:39 by jwe]
jwe
parents: 2475
diff changeset
1757 #endif
14111
c5222658dc3c doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents: 14022
diff changeset
1758 }
2669
c821858188b6 [project @ 1997-02-13 18:25:39 by jwe]
jwe
parents: 2475
diff changeset
1759
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1760 DEFUNX ("O_TRUNC", FO_TRUNC, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1761 "-*- 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
1762 @deftypefn {} {} O_TRUNC ()\n\
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1763 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
1764 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
1765 truncated when writing.\n\
5333
ac8d64b9e76a [project @ 2005-05-02 18:15:20 by jwe]
jwe
parents: 5307
diff changeset
1766 @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
1767 @end deftypefn")
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1768 {
14111
c5222658dc3c doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents: 14022
diff changeset
1769 #if defined (O_TRUNC)
7924
4976f66d469b miscellaneous cleanup
John W. Eaton <jwe@octave.org>
parents: 7096
diff changeset
1770 return const_value (args, O_TRUNC);
14111
c5222658dc3c doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents: 14022
diff changeset
1771 #else
c5222658dc3c doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents: 14022
diff changeset
1772 error ("O_TRUNC: not available on this system");
c5222658dc3c doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents: 14022
diff changeset
1773 return octave_value ();
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1774 #endif
14111
c5222658dc3c doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents: 14022
diff changeset
1775 }
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1776
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1777 DEFUNX ("O_WRONLY", FO_WRONLY, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1778 "-*- 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
1779 @deftypefn {} {} O_WRONLY ()\n\
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1780 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
1781 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
1782 @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
1783 @end deftypefn")
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1784 {
14111
c5222658dc3c doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents: 14022
diff changeset
1785 #if defined (O_WRONLY)
7924
4976f66d469b miscellaneous cleanup
John W. Eaton <jwe@octave.org>
parents: 7096
diff changeset
1786 return const_value (args, O_WRONLY);
14111
c5222658dc3c doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents: 14022
diff changeset
1787 #else
c5222658dc3c doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents: 14022
diff changeset
1788 error ("O_WRONLY: not available on this system");
c5222658dc3c doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents: 14022
diff changeset
1789 return octave_value ();
c5222658dc3c doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents: 14022
diff changeset
1790 #endif
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1791 }
3446
5ee5afb3981a [project @ 2000-01-17 09:42:43 by jwe]
jwe
parents: 3360
diff changeset
1792
20791
f7084eae3318 maint: Use Octave coding conventions for #if statements.
Rik <rik@octave.org>
parents: 20764
diff changeset
1793 #if ! defined (WNOHANG)
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1794 #define WNOHANG 0
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1795 #endif
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1796
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1797 DEFUNX ("WNOHANG", FWNOHANG, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1798 "-*- 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
1799 @deftypefn {} {} WNOHANG ()\n\
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1800 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
1801 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
1802 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
1803 @seealso{waitpid, WUNTRACED, WCONTINUE}\n\
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1804 @end deftypefn")
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1805 {
7924
4976f66d469b miscellaneous cleanup
John W. Eaton <jwe@octave.org>
parents: 7096
diff changeset
1806 return const_value (args, WNOHANG);
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1807 }
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1808
20791
f7084eae3318 maint: Use Octave coding conventions for #if statements.
Rik <rik@octave.org>
parents: 20764
diff changeset
1809 #if ! defined (WUNTRACED)
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1810 #define WUNTRACED 0
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1811 #endif
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1812
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1813 DEFUNX ("WUNTRACED", FWUNTRACED, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1814 "-*- 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
1815 @deftypefn {} {} WUNTRACED ()\n\
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1816 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
1817 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
1818 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
1819 @seealso{waitpid, WNOHANG, WCONTINUE}\n\
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1820 @end deftypefn")
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1821 {
7924
4976f66d469b miscellaneous cleanup
John W. Eaton <jwe@octave.org>
parents: 7096
diff changeset
1822 return const_value (args, WUNTRACED);
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1823 }
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1824
20791
f7084eae3318 maint: Use Octave coding conventions for #if statements.
Rik <rik@octave.org>
parents: 20764
diff changeset
1825 #if ! defined (WCONTINUE)
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1826 #define WCONTINUE 0
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1827 #endif
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5333
diff changeset
1828
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1829 DEFUNX ("WCONTINUE", FWCONTINUE, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1830 "-*- 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
1831 @deftypefn {} {} WCONTINUE ()\n\
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1832 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
1833 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
1834 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
1835 @seealso{waitpid, WNOHANG, WUNTRACED}\n\
5749
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1836 @end deftypefn")
26beffa9f66f [project @ 2006-04-07 20:35:07 by jwe]
jwe
parents: 5656
diff changeset
1837 {
7924
4976f66d469b miscellaneous cleanup
John W. Eaton <jwe@octave.org>
parents: 7096
diff changeset
1838 return const_value (args, WCONTINUE);
2075
ad74682dc97e [project @ 1996-04-23 23:59:15 by jwe]
jwe
parents:
diff changeset
1839 }