Skip to content

Commit 3bdfcfa

Browse files
authored
Merge pull request #695 from JunoLab/sp/betterinterrupts
improve interrupt handling
2 parents 2973309 + 6308217 commit 3bdfcfa

File tree

5 files changed

+3
-164
lines changed

5 files changed

+3
-164
lines changed

lib/connection/client.coffee

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,10 +141,7 @@ module.exports =
141141

142142
interrupt: ->
143143
if @isActive()
144-
if @isWorking()
145-
@clientCall 'interrupts', 'interrupt'
146-
else
147-
@clientCall 'interrupts', 'interruptREPL'
144+
@clientCall 'interrupts', 'interrupt'
148145

149146
disconnect: ->
150147
if @isActive()

lib/connection/process/basic.js

Lines changed: 2 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,7 @@ export function get (path, args) {
2020

2121
export function get_ (path, args) {
2222
const env = customEnv()
23-
if (process.platform == 'win32') {
24-
return getWindows(path, args, env)
25-
} else {
26-
return getUnix(path, args, env)
27-
}
23+
return getUnix(path, args, env)
2824
}
2925

3026
export function customEnv (env = process.env) {
@@ -47,8 +43,6 @@ export function customEnv (env = process.env) {
4743
return env
4844
}
4945

50-
// TODO: reduce code duplication in getUnix and getWindows
51-
5246
function getUnix (path, args, env) {
5347
return new Promise((resolve, reject) => {
5448
tcp.listen().then((port) => {
@@ -70,10 +64,7 @@ function getUnix (path, args, env) {
7064
let proc = {
7165
ty: ty,
7266
kill: () => ty.kill(),
73-
interrupt: () => ty.kill('SIGINT'),
74-
// more robust REPL-only interrupt, in theory only needed on windows
75-
// without powershell wrapper:
76-
interruptREPL: () => ty.write('\x03'),
67+
interrupt: () => ty.write('\x03'),
7768
socket: sock,
7869
onExit: (f) => ty.on('exit', f),
7970
onStderr: (f) => {},
@@ -93,71 +84,6 @@ function getUnix (path, args, env) {
9384
})
9485
}
9586

96-
function getWindows (path, args, env) {
97-
if (!atom.config.get('julia-client.juliaOptions.enablePowershellWrapper')) {
98-
return getUnix(path, args, env)
99-
}
100-
return new Promise((resolve, reject) => {
101-
tcp.listen().then((port) => {
102-
freePort().then((wrapPort) => {
103-
paths.fullPath("powershell").then((psPath) => {
104-
paths.projectDir().then((cwd) => {
105-
let jlargs = [...args, '"`"' + paths.script('boot_repl.jl') + '`""', ` ${port}`]
106-
let ty = pty.spawn(psPath,
107-
["-NoProfile", "-ExecutionPolicy", "bypass",
108-
`& \"${paths.script('spawnInterruptible.ps1')}\"`,
109-
`-wrapPort ${wrapPort}`,
110-
`-jlpath \"${path}\"`,
111-
`-jlargs ${jlargs}`], {
112-
cols: 100,
113-
rows: 30,
114-
env: env,
115-
useConpty: true
116-
})
117-
118-
let sock = socket(ty)
119-
sock.catch((err) => reject(err))
120-
121-
let proc = {
122-
ty: ty,
123-
kill: () => {
124-
sendSignalToWrapper('KILL', wrapPort)
125-
ty.kill()
126-
},
127-
interrupt: () => sendSignalToWrapper('SIGINT', wrapPort),
128-
// more robust REPL-only interrupt, in theory only needed on windows
129-
// without powershell wrapper:
130-
interruptREPL: () => ty.write('\x03'),
131-
socket: sock,
132-
onExit: (f) => ty.on('exit', f),
133-
onStderr: (f) => {},
134-
onStdout: (f) => ty.on('data', f)
135-
}
136-
137-
resolve(proc)
138-
}).catch((err) => {
139-
reject(err)
140-
})
141-
}).catch((err) => {
142-
atom.notifications.addError('Julia could not be started.', {
143-
description: "We tried to start Julia with the `powershell` wrapper but "+
144-
"could not find `powershell` or `where` on your `PATH`. Please make sure "+
145-
"`%SYSTEMROOT%\\System32\\WindowsPowerShell\\v1.0` and "+
146-
"`%SYSTEMROOT%\\System32` are on your `PATH` and restart Juno.",
147-
detail: err,
148-
dismissable: true
149-
})
150-
reject(err)
151-
})
152-
}).catch((err) => {
153-
reject(err)
154-
})
155-
}).catch((err) => {
156-
reject(err)
157-
})
158-
})
159-
}
160-
16187
function freePort() {
16288
return new Promise((resolve) => {
16389
let server = net.createServer()
@@ -169,13 +95,6 @@ function freePort() {
16995
})
17096
}
17197

172-
function sendSignalToWrapper(signal, port) {
173-
let wrapper = net.connect({port})
174-
wrapper.setNoDelay()
175-
wrapper.write(signal)
176-
wrapper.end()
177-
}
178-
17998
function socket (ty) {
18099
conn = tcp.next()
181100
failure = new Promise((resolve, reject) => {

lib/connection/process/remote.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,6 @@ export function get_ (path, args) {
238238
kill: () => stream.signal('KILL'),
239239
disconnect: () => stream.close(),
240240
interrupt: () => stream.write('\x03'), // signal handling doesn't seem to work :/
241-
interruptREPL: () => stream.write('\x03'),
242241
socket: sock,
243242
onExit: (f) => stream.on('close', f),
244243
onStderr: (f) => stream.stderr.on('data', data => f(data.toString())),

lib/package/config.coffee

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -637,12 +637,4 @@ if process.platform == 'darwin'
637637
default: false
638638
order: 5.5
639639

640-
if process.platform == 'win32'
641-
config.juliaOptions.properties.enablePowershellWrapper =
642-
title: 'Enable Powershell Wrapper'
643-
type: 'boolean'
644-
default: true
645-
description: 'If enabled, use a Powershell wrapper to spawn Julia. Necessary to enable interrupts.'
646-
order: 99
647-
648640
module.exports = config

script/spawnInterruptible.ps1

Lines changed: 0 additions & 68 deletions
This file was deleted.

0 commit comments

Comments
 (0)