1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
|
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing
**
** This file is part of Qbs.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms and
** conditions see http://www.qt.io/terms-conditions. For further information
** use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, The Qt Company gives you certain additional
** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
/*!
\contentspage index.html
\page jsextension-process.html
\ingroup list-of-builtin-services
\title Process Service
\brief Allows you to start external processes.
The \c Process service allows you to start processes, track their output,
and so on.
\section1 Available Operations
\section2 Constructor
\code
Process()
\endcode
Allocates and returns a new Process object.
\section2 close
\code
close(): void
\endcode
Frees the resources associated with the process. It is recommended to always call this function as
soon as you are finished with the process.
\section2 closeWriteChannel
\code
closeWriteChannel(): void
\endcode
Schedules the stdin channel of process to be closed. The channel will close once all data has been
written to the process. After calling this function, any attempts to write to the process will do
nothing. See \c QProcess::closeWriteChannel() for more details.
\section2 exec
\code
exec(filePath: string, arguments: string[], throwOnError: boolean): number
\endcode
Executes the program at \c filePath with the given argument list and blocks until the
process is finished. If an error occurs (for example, there is no executable
file at \c filePath)
and \c throwOnError is true, then a JavaScript exception will be thrown. Otherwise
(the default), -1 will be returned in case of an error. The normal return code is the exit code
of the process.
\section2 exitCode
\code
exitCode(): number
\endcode
Returns the exit code of the process. This is needed for retrieving the exit code from
processes started via \c start(), rather than \c exec().
\section2 getEnv
\code
getEnv(varName: string): string
\endcode
Returns the value of the variable \c varName in the process' environment.
\section2 kill
\code
kill(): void
\endcode
Kills the process, causing it to exit immediately.
\section2 readLine
\code
readLine(): string
\endcode
Reads and returns one line of text from the process output, without the newline character(s).
\section2 readStdErr
\code
readStdErr(): string
\endcode
Reads and returns all data from the process' standard error channel.
\section2 readStdOut
\code
readStdOut(): string
\endcode
Reads and returns all data from the process' standard output channel.
\section2 setCodec
\code
setCodec(codec)
\endcode
Sets the text codec to \c codec. The codec is used for reading and writing from and to
the process, respectively. The supported codecs are the same as for \c QTextCodec, for example:
"UTF-8", "UTF-16", and "ISO 8859-1".
\section2 setEnv
\code
setEnv(varName: string, varValue: string): string
\endcode
Sets the value of variable \c varName to \c varValue in the process environment.
This only has an effect if called before the process is started.
\section2 setWorkingDirectory
\code
setWorkingDirectory(path: string): void
\endcode
Sets the directory the process will be started in.
This only has an effect if called before the process is started.
\section2 start
\code
start(filePath: string, arguments: string[]): boolean
\endcode
Starts the program at \c filePath with the given list of arguments. Returns \c{true} if the
process could be started and \c{false} otherwise.
\note This call returns right after starting the process and should be used only if you need
to interact with the process while it is running. Most of the time, you want to use \c exec()
instead.
\section2 terminate
\code
terminate(): void
\endcode
Tries to terminate the process. This is not guaranteed to make the process exit immediately;
if you need that, use \c kill().
\section2 waitForFinished
\code
waitForFinished(timeout: number): boolean
\endcode
Blocks until the process has finished or \c timeout milliseconds have passed (default is 30000).
Returns true if the process has finished and false if the operation has timed out.
Calling this function only makes sense for processes started via \c start() (as opposed to
\c exec()).
\section2 workingDirectory
\code
workingDirectory(): string
\endcode
Returns the directory the process will be started in.
\section2 write
\code
write(data: string): void
\endcode
Writes \c data into the process' input channel.
\section2 writeLine
\code
writeLine(data: string): void
\endcode
Writes \c data, followed by the newline character(s), into the process' input channel.
*/
|