Skip to content

Commit b293c90

Browse files
authored
Merge pull request #473 from grondo/spec42-bgv2
rfc42: use RPC streaming flag instead of explicit background flag
2 parents b48f81a + f4784f1 commit b293c90

File tree

1 file changed

+26
-16
lines changed

1 file changed

+26
-16
lines changed

spec_42.rst

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,21 @@ Implementation
9797
exec
9898
====
9999

100-
The exec RPC creates a new subprocess. The RPC MUST be initiated with a
101-
streaming request as defined in RFC 6 unless the ``background`` flag is set
102-
(see below), in which case it MUST be initiated with a non-streaming request.
103-
Payloads are defined as follows:
100+
The exec RPC creates a new subprocess. The behavior depends on whether the
101+
RPC is initiated with a streaming or non-streaming request as defined in
102+
RFC 6.
103+
104+
Streaming request: When initiated with a streaming request, responses
105+
(defined below) SHALL be sent until the process terminates and all output
106+
has been delivered. If the requesting process disconnects, the subprocess
107+
SHALL be terminated.
108+
109+
Non-streaming request (background mode): When initiated with a non-streaming
110+
request, a single response SHALL be sent: either an :program:`exec started`
111+
response if successful, or an :program:`exec error` response on failure. The
112+
subprocess SHALL continue running as a child of the subprocess server until
113+
it terminates or the server is shut down. The server MAY log subprocess
114+
output and exit code to its own log stream.
104115

105116
.. object:: exec request
106117

@@ -116,6 +127,10 @@ Payloads are defined as follows:
116127

117128
(*integer*, REQUIRED) A bitfield comprised of zero or more flags:
118129

130+
..note::
131+
132+
These flags are ignored in background mode.
133+
119134
stdout (1)
120135
Forward standard output to the client.
121136

@@ -129,15 +144,6 @@ Payloads are defined as follows:
129144
Send ``add-credit`` exec responses when buffer space is available
130145
for standard input or writable auxiliary channels.
131146

132-
background (16)
133-
Run subprocess in the background. The server SHALL send exactly one
134-
response upon execution: :program:`exec started` if successful, or
135-
:program:`exec error` if execution fails. When execution is successful,
136-
the subprocess SHALL continue running as a child process of the
137-
server until either the subprocess completes or the server shuts
138-
down. When the ``background`` flag is set, the server SHALL ignore
139-
the ``stdout``, ``stderr``, ``channel``, and ``write-credit`` flags.
140-
141147
.. object:: local_flags
142148

143149
(*integer*, OPTIONAL) A bitfield comprised of zero or more flags:
@@ -233,7 +239,7 @@ Several response types are distinguished by the type key:
233239

234240
.. object:: exec error response
235241

236-
When the ``background`` flag is not set, the :program:`exec` response
242+
When initiated with a streaming request, the :program:`exec` response
237243
stream SHALL be terminated by an error response per RFC 6, with ENODATA
238244
(61) indicating success. The server MUST send :program:`exec started`,
239245
:program:`exec finished`, and :program:`exec output` responses with EOF
@@ -242,12 +248,16 @@ flag set for each open channel before terminating with ENODATA.
242248
The client MAY consider it a protocol error if one of those responses is
243249
missing and an ENODATA response is received.
244250

245-
When the ``background`` flag is not set, failure of the remote command SHALL
246-
be indicated in finished response and SHALL NOT result in an error response.
251+
Failure of the remote command SHALL be indicated in finished response and
252+
SHALL NOT result in an error response.
247253

248254
Other errors, such as an ENOENT error from the :func:`execvp` system call
249255
SHALL result in an error response.
250256

257+
When initiated with a non-streaming request, an :program:`exec error`
258+
response SHALL NOT be sent if a failure occurs after a successful call to
259+
:func:`execvp`.
260+
251261
write
252262
=====
253263

0 commit comments

Comments
 (0)