使用ShellJs命令停止程序。

huangapple go评论83阅读模式
英文:

Stop program with ShellJs command

问题

我正在使用codeceptjsshelljs

在其中一个测试中,我像这样调用了一个Go应用程序:

const shell = require('shelljs')

let execution = shell.exec('./myGoApplication')
execution.kill();

我尝试使用不同的参数使用kill来停止它,但它不起作用。

有人知道如何停止运行Go应用程序吗?

编辑:

这段代码也无法停止

execution.kill('SIGINT');

https://github.com/shelljs/shelljs

英文:

I'm using codeceptjs with shelljs.

In one of tests I'm invoking a Go application like this:

const shell = require('shelljs')


let execution = shell.exec('./myGoApplication')
execution.kill();

I tried to stop it with kill with different params but it is not working.

Does anyone knows how to stop Go application from running?

EDIT:

This code doesn't stop either

execution.kill('SIGINT');

https://github.com/shelljs/shelljs

答案1

得分: 1

kill命令将终止信号作为其第一个参数接受。

let execution = shell.exec('./myGoApplication');
execution.kill('SIGINT');

这是所有信号的列表:

https://unix.stackexchange.com/a/317496

英文:

The kill command accepts the termination signal as its first argument.

let execution = shell.exec('./myGoApplication')
execution.kill('SIGINT');

Here is a list of all signals:

https://unix.stackexchange.com/a/317496

huangapple
  • 本文由 发表于 2021年8月9日 17:41:35
  • 转载请务必保留本文链接:https://go.coder-hub.com/68709941.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定