This thread seems be related.
I found this workaround:
begin
# Command for drawing a spinner
command = "
t=Threads.@async read(stdin, Char)
while !istaskdone(t)
for q=['\\\\','|','/','-']
print('\b',q)
sleep(0.1)
end
end
exit()"
# Draw spinner as a separate process
proc_input = Pipe();
proc = run(pipeline(`julia -e $command`,stdin = proc_input, stdout = stdout), wait = false)
sleep(1)
kill(proc) # Process is signaled, but it keeps running
sleep(2)
write(proc_input,'c') # Process finishes when it reads from its stdin
sleep(0.5)
println()
end
Instead of relying on kill(), the main process writes to the stdin of the spawned process, and this is interpreted as a sort of kill signal.
In practice, the main drawback is that I haven’t found any way for the spawned process to receive signals both from the user and from the main process.