I've created a node.js program that gets keypress input from stdin
by using setRawMode(true)
, per this. I've already made it so ^C
and ^D
(control-C/control-D) are handled; the code basically looks like this:
process.stdin.setRawMode(true)
process.stdin.on('data', data => {
if (Buffer.from([0x03]).equals(data) || Buffer.from([0x04]).equals(data)) {
process.exit()
}
})
It's quite easy to fake how ^C
and ^D
work simply by, well, causing the program to exit. But how can I make ^Z
work? Obviously I can't fake it, because it's something bash normally deals with itself. Is there some way to tell bash/sh/whatever to put the program into the background, the way ^Z normally works?