annotate src/syscalls.cc @ 12514:e5e66c389597

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