@@ -111,6 +111,7 @@ class Main {
111
111
112
112
QObject::connect (&process, qOverload<int >(&QProcess::finished), [this ](int code) {
113
113
const QByteArray msg = QString (" *exited:%0" ).arg (code).toUtf8 ();
114
+ exitCode = code;
114
115
write (controlFd, msg.data (), msg.size () + 1 );
115
116
if (autoQuit) {
116
117
QCoreApplication::instance ()->quit ();
@@ -123,6 +124,10 @@ class Main {
123
124
process.start ();
124
125
}
125
126
127
+ int getExitCode () {
128
+ return exitCode;
129
+ }
130
+
126
131
private:
127
132
void sendToInterior (char * data, ssize_t len) {
128
133
::write (process.masterFd, data, static_cast <size_t >(len));
@@ -308,6 +313,7 @@ class Main {
308
313
QByteArray pendingControlData;
309
314
VTermScreenCallbacks screenCallbacks;
310
315
VTermStateFallbacks unhandled;
316
+ int exitCode = 22 ;
311
317
312
318
// buffered screen state
313
319
bool cursorVisible = true ;
@@ -338,6 +344,7 @@ int main(int argc, char** argv) {
338
344
parser.setOptionsAfterPositionalArgumentsMode (QCommandLineParser::ParseAsPositionalArguments);
339
345
parser.addPositionalArgument (" command" , " Command to execute and connect to the terminal" );
340
346
parser.addOption ({ " control-via-fd0" , " control communication is via fd 0." });
347
+ parser.addOption ({ " propagate-exit-code" , " Propagate exist code from inner command to driver exit code." });
341
348
parser.process (app);
342
349
const QStringList args = parser.positionalArguments ();
343
350
@@ -350,5 +357,5 @@ int main(int argc, char** argv) {
350
357
351
358
app.exec ();
352
359
353
- return 0 ;
360
+ return parser. isSet ( " propagate-exit-code " ) ? m. getExitCode () : 0 ;
354
361
}
0 commit comments