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