@@ -8,6 +8,7 @@ import { SendableConnection } from "../common/connection";
8
8
import { ServerOptions } from "./server" ;
9
9
10
10
export interface Process {
11
+ stdio ?: Array < stream . Readable | stream . Writable > ;
11
12
stdin ?: stream . Writable ;
12
13
stdout ?: stream . Readable ;
13
14
stderr ?: stream . Readable ;
@@ -69,27 +70,34 @@ export const handleNewSession = (connection: SendableConnection, newSession: New
69
70
} ;
70
71
}
71
72
72
- const sendOutput = ( _fd : SessionOutputMessage . FD , msg : string | Uint8Array ) : void => {
73
+ const sendOutput = ( _source : SessionOutputMessage . Source , msg : string | Uint8Array ) : void => {
73
74
const serverMsg = new ServerMessage ( ) ;
74
75
const d = new SessionOutputMessage ( ) ;
75
76
d . setId ( newSession . getId ( ) ) ;
76
77
d . setData ( typeof msg === "string" ? new TextEncoder ( ) . encode ( msg ) : msg ) ;
77
- d . setFd ( SessionOutputMessage . FD . STDOUT ) ;
78
+ d . setSource ( _source ) ;
78
79
serverMsg . setSessionOutput ( d ) ;
79
80
connection . send ( serverMsg . serializeBinary ( ) ) ;
80
81
} ;
81
82
82
83
if ( process . stdout && process . stderr ) {
83
84
process . stdout . on ( "data" , ( data ) => {
84
- sendOutput ( SessionOutputMessage . FD . STDOUT , data ) ;
85
+ sendOutput ( SessionOutputMessage . Source . STDOUT , data ) ;
85
86
} ) ;
86
87
87
88
process . stderr . on ( "data" , ( data ) => {
88
- sendOutput ( SessionOutputMessage . FD . STDERR , data ) ;
89
+ sendOutput ( SessionOutputMessage . Source . STDERR , data ) ;
89
90
} ) ;
90
91
} else {
91
92
process . on ( "data" , ( data ) => {
92
- sendOutput ( SessionOutputMessage . FD . STDOUT , Buffer . from ( data ) ) ;
93
+ sendOutput ( SessionOutputMessage . Source . STDOUT , Buffer . from ( data ) ) ;
94
+ } ) ;
95
+ }
96
+
97
+ if ( process . stdio && process . stdio [ 3 ] ) {
98
+ // We have ipc fd
99
+ process . stdio [ 3 ] . on ( "data" , ( data ) => {
100
+ sendOutput ( SessionOutputMessage . Source . IPC , data ) ;
93
101
} ) ;
94
102
}
95
103
0 commit comments