mirror of
https://github.com/HeyPuter/puter
synced 2024-11-15 06:15:47 +00:00
dev: handle pty close
Return to phoenix shell when a pty stream is closed by twisp. Pipes in phoenix with commands from the emulator do not appear to be working properly, but something in there is working.
This commit is contained in:
parent
d3e70ebe82
commit
baeb79b502
@ -91,8 +91,13 @@ puter.ui.on('connection', event => {
|
||||
conn.off('message', pty_on_first_message);
|
||||
console.log('[!!] message from connection', message);
|
||||
const pty = ptyMgr.getPTY({
|
||||
command: '/bin/bash'
|
||||
command: message.command,
|
||||
});
|
||||
pty.on_close = () => {
|
||||
conn.postMessage({
|
||||
$: 'pty.close',
|
||||
});
|
||||
}
|
||||
console.log('setting up ptt with...', conn);
|
||||
const ptt = new XDocumentPTT(conn, {
|
||||
disableReader: true,
|
||||
@ -185,6 +190,10 @@ window.onload = async function()
|
||||
console.log('stream id?', packet.streamId);
|
||||
const pty = this.stream_listeners_[packet.streamId];
|
||||
pty.on_payload(packet.payload);
|
||||
},
|
||||
[WispPacket.CLOSE.id]: function ({ packet }) {
|
||||
const pty = this.stream_listeners_[packet.streamId];
|
||||
pty.on_close();
|
||||
}
|
||||
},
|
||||
on: function () {
|
||||
|
@ -5,6 +5,7 @@ export class EmuCommandProvider {
|
||||
static AVAILABLE = {
|
||||
'bash': '/bin/bash',
|
||||
'htop': '/usr/bin/htop',
|
||||
'emu-sort': '/usr/bin/sort',
|
||||
};
|
||||
|
||||
static EMU_APP_NAME = 'test-emu';
|
||||
@ -93,6 +94,9 @@ export class EmuCommandProvider {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (message.$ === 'pty.close') {
|
||||
app_close_promise.resolve();
|
||||
}
|
||||
});
|
||||
|
||||
// Repeatedly copy data from stdin to the child, while it's running.
|
||||
@ -121,7 +125,6 @@ export class EmuCommandProvider {
|
||||
args: [],
|
||||
});
|
||||
|
||||
const never_resolve = new TeePromise();
|
||||
await never_resolve;
|
||||
await app_close_promise;
|
||||
}
|
||||
}
|
||||
|
@ -223,6 +223,18 @@ const wisp_types = [
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
label: 'CLOSE',
|
||||
describe: ({ attributes }) => {
|
||||
return `reason: ${attributes.code}`;
|
||||
},
|
||||
getAttributes ({ payload }) {
|
||||
return {
|
||||
code: payload[0],
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
// TODO: extension types should not be hardcoded here
|
||||
id: 0xf0,
|
||||
|
Loading…
Reference in New Issue
Block a user