mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
repl: fix ctrl+z job to background on linux (#6417)
This commit is contained in:
parent
d2badcdedf
commit
46dc6cc24b
@ -7,9 +7,11 @@
|
||||
module readline
|
||||
|
||||
import term
|
||||
import os
|
||||
|
||||
#include <termios.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
// Defines actions to execute
|
||||
enum Action {
|
||||
eof
|
||||
@ -35,9 +37,12 @@ fn C.tcgetattr() int
|
||||
|
||||
fn C.tcsetattr() int
|
||||
|
||||
// fn C.ioctl() int
|
||||
fn C.raise()
|
||||
|
||||
fn C.kill(int, int) int
|
||||
|
||||
fn C.getppid() int
|
||||
|
||||
// Enable the raw mode of the terminal
|
||||
// In raw mode all keypresses are directly sent to the program and no interpretation is done
|
||||
// Catches the SIGUSER (CTRL+C) Signal
|
||||
@ -480,6 +485,18 @@ fn (mut r Readline) history_next() {
|
||||
}
|
||||
|
||||
fn (mut r Readline) suspend() {
|
||||
is_standalone := os.getenv('VCHILD') != 'true'
|
||||
|
||||
r.disable_raw_mode()
|
||||
if !is_standalone {
|
||||
// We have to SIGSTOP the parent v process
|
||||
ppid := C.getppid()
|
||||
C.kill(ppid, C.SIGSTOP)
|
||||
}
|
||||
C.raise(C.SIGSTOP)
|
||||
r.enable_raw_mode()
|
||||
r.refresh_line()
|
||||
if r.is_tty {
|
||||
r.refresh_line()
|
||||
}
|
||||
}
|
||||
|
@ -111,6 +111,7 @@ pub fn set_vroot_folder(vroot_path string) {
|
||||
// can return it later to whoever needs it:
|
||||
vname := if os.user_os() == 'windows' { 'v.exe' } else { 'v' }
|
||||
os.setenv('VEXE', os.real_path(os.join_path(vroot_path, vname)), true)
|
||||
os.setenv('VCHILD', 'true', true)
|
||||
}
|
||||
|
||||
pub fn resolve_vroot(str, dir string) ?string {
|
||||
|
Loading…
Reference in New Issue
Block a user