kill-java.js 762 B

12345678910111213141516171819202122232425262728
  1. /*
  2. * Copyright 2019-2022 Mamoe Technologies and contributors.
  3. *
  4. * 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
  5. * Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
  6. *
  7. * https://github.com/mamoe/mirai/blob/dev/LICENSE
  8. */
  9. let ostype = require('os').type();
  10. let child_process = require('child_process');
  11. if (ostype.toLowerCase().indexOf('windows') !== -1) {
  12. child_process.spawnSync('taskkill',
  13. ['/f', '/im', 'java*'],
  14. {
  15. stdio: "inherit"
  16. }
  17. );
  18. } else {
  19. child_process.spawnSync('pkill',
  20. ['-9', 'java'],
  21. {
  22. stdio: "inherit"
  23. }
  24. );
  25. }