Skip to content

Commit

Permalink
cmd -> cmd.exe (microsoft#1603)
Browse files Browse the repository at this point in the history
  • Loading branch information
Yuge Zhang authored and QuanluZhang committed Oct 14, 2019
1 parent 5bd994d commit ca2253c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions src/nni_manager/common/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -445,10 +445,10 @@ function getTunerProc(command: string, stdio: StdioOptions, newCwd: string, newE
/**
* 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 alive: boolean = false;
if(process.platform ==='win32'){
if (process.platform === 'win32') {
try {
const str = cp.execSync(`powershell.exe Get-Process -Id ${pid} -ErrorAction SilentlyContinue`).toString();
if (str) {
Expand All @@ -458,7 +458,7 @@ async function isAlive(pid:any): Promise<boolean> {
catch (error) {
}
}
else{
else {
try {
await cpp.exec(`kill -0 ${pid}`);
alive = true;
Expand All @@ -473,11 +473,11 @@ async function isAlive(pid:any): Promise<boolean> {
/**
* kill process
*/
async function killPid(pid:any): Promise<void> {
async function killPid(pid: any): Promise<void> {
let deferred : Deferred<void> = new Deferred<void>();
try {
if (process.platform === "win32") {
await cpp.exec(`cmd /c taskkill /PID ${pid} /F`);
await cpp.exec(`cmd.exe /c taskkill /PID ${pid} /F`);
}
else{
await cpp.exec(`kill -9 ${pid}`);
Expand Down
2 changes: 1 addition & 1 deletion src/nni_manager/training_service/common/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ export async function execRemove(directory: string): Promise<void> {
*/
export async function execKill(pid: string): Promise<void> {
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 {
await cpp.exec(`pkill -P ${pid}`);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ class LocalTrainingService implements TrainingService {
const script: string[] = [];
if (process.platform === 'win32') {
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 = "$NOW_DATE" + (Get-Date -Format fff).ToString()`,
`Write $LASTEXITCODE " " $NOW_DATE | Out-File ${path.join(workingDirectory, '.nni', 'state')} -NoNewline -encoding utf8`);
Expand Down

0 comments on commit ca2253c

Please sign in to comment.