Commit ca2253c3 authored by Yuge Zhang's avatar Yuge Zhang Committed by QuanluZhang
Browse files

cmd -> cmd.exe (#1603)

parent 5bd994de
...@@ -445,10 +445,10 @@ function getTunerProc(command: string, stdio: StdioOptions, newCwd: string, newE ...@@ -445,10 +445,10 @@ function getTunerProc(command: string, stdio: StdioOptions, newCwd: string, newE
/** /**
* judge whether the process is alive * judge whether the process is alive
*/ */
async function isAlive(pid:any): Promise<boolean> { async function isAlive(pid: any): Promise<boolean> {
let deferred : Deferred<boolean> = new Deferred<boolean>(); let deferred : Deferred<boolean> = new Deferred<boolean>();
let alive: boolean = false; let alive: boolean = false;
if(process.platform ==='win32'){ if (process.platform === 'win32') {
try { try {
const str = cp.execSync(`powershell.exe Get-Process -Id ${pid} -ErrorAction SilentlyContinue`).toString(); const str = cp.execSync(`powershell.exe Get-Process -Id ${pid} -ErrorAction SilentlyContinue`).toString();
if (str) { if (str) {
...@@ -458,7 +458,7 @@ async function isAlive(pid:any): Promise<boolean> { ...@@ -458,7 +458,7 @@ async function isAlive(pid:any): Promise<boolean> {
catch (error) { catch (error) {
} }
} }
else{ else {
try { try {
await cpp.exec(`kill -0 ${pid}`); await cpp.exec(`kill -0 ${pid}`);
alive = true; alive = true;
...@@ -473,11 +473,11 @@ async function isAlive(pid:any): Promise<boolean> { ...@@ -473,11 +473,11 @@ async function isAlive(pid:any): Promise<boolean> {
/** /**
* kill process * kill process
*/ */
async function killPid(pid:any): Promise<void> { async function killPid(pid: any): Promise<void> {
let deferred : Deferred<void> = new Deferred<void>(); let deferred : Deferred<void> = new Deferred<void>();
try { try {
if (process.platform === "win32") { if (process.platform === "win32") {
await cpp.exec(`cmd /c taskkill /PID ${pid} /F`); await cpp.exec(`cmd.exe /c taskkill /PID ${pid} /F`);
} }
else{ else{
await cpp.exec(`kill -9 ${pid}`); await cpp.exec(`kill -9 ${pid}`);
......
...@@ -156,7 +156,7 @@ export async function execRemove(directory: string): Promise<void> { ...@@ -156,7 +156,7 @@ export async function execRemove(directory: string): Promise<void> {
*/ */
export async function execKill(pid: string): Promise<void> { export async function execKill(pid: string): Promise<void> {
if (process.platform === 'win32') { if (process.platform === 'win32') {
await cpp.exec(`cmd /c taskkill /PID ${pid} /T /F`); await cpp.exec(`cmd.exe /c taskkill /PID ${pid} /T /F`);
} else { } else {
await cpp.exec(`pkill -P ${pid}`); await cpp.exec(`pkill -P ${pid}`);
} }
......
...@@ -490,7 +490,7 @@ class LocalTrainingService implements TrainingService { ...@@ -490,7 +490,7 @@ class LocalTrainingService implements TrainingService {
const script: string[] = []; const script: string[] = [];
if (process.platform === 'win32') { if (process.platform === 'win32') {
script.push( script.push(
`cmd /c ${localTrialConfig.command} 2>${path.join(workingDirectory, 'stderr')}`, `cmd.exe /c ${localTrialConfig.command} 2>${path.join(workingDirectory, 'stderr')}`,
`$NOW_DATE = [int64](([datetime]::UtcNow)-(get-date "1/1/1970")).TotalSeconds`, `$NOW_DATE = [int64](([datetime]::UtcNow)-(get-date "1/1/1970")).TotalSeconds`,
`$NOW_DATE = "$NOW_DATE" + (Get-Date -Format fff).ToString()`, `$NOW_DATE = "$NOW_DATE" + (Get-Date -Format fff).ToString()`,
`Write $LASTEXITCODE " " $NOW_DATE | Out-File ${path.join(workingDirectory, '.nni', 'state')} -NoNewline -encoding utf8`); `Write $LASTEXITCODE " " $NOW_DATE | Out-File ${path.join(workingDirectory, '.nni', 'state')} -NoNewline -encoding utf8`);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment