1- import { ChildProcess , spawn } from "child_process" ;
1+ import { spawn } from "child_process" ;
22import { getLogger } from "log4js" ;
3+ import { constants } from "os" ;
34import { BasicSpawnOption , CompleteStdioOptions } from "./BasicSpawn" ;
45import { MeteredChildProcess } from "./Meter" ;
5- import { constants } from "os" ;
6- import { getConfig } from "../Config" ;
76
87const logger = getLogger ( "JailMeterSpawn" ) ;
98
@@ -22,33 +21,14 @@ export interface HengSpawnOption {
2221 gid ?: number ; // nsjail(append root), meter
2322}
2423
25- export function loggedSpawn (
26- spawnFunction : ( command : string , args : string [ ] ) => ChildProcess
27- ) : ( command : string , args : string [ ] ) => ChildProcess {
28- return function ( command : string , args : string [ ] ) {
29- logger . info ( `${ command } ${ args . join ( " " ) } ` ) ;
30- return spawnFunction ( command , args ) ;
31- } ;
32- }
33-
34- // intended typo, seted => set
35- export function optionSetedSpawn < V , T > (
36- spawn : ( command : string , args : string [ ] , options : V ) => T ,
37- options : V
38- ) : ( command : string , args : string [ ] ) => T {
39- return function ( command : string , args : string [ ] ) {
40- return spawn ( command , args , options ) ;
41- } ;
42- }
43-
4424export function hengSpawn (
4525 command : string ,
4626 args : string [ ] ,
4727 options : HengSpawnOption
4828) : MeteredChildProcess {
4929 const basicOption : BasicSpawnOption = {
5030 cwd : options . cwd ,
51- shell : getConfig ( ) . language . shell ,
31+ // shell: getConfig().language.shell,
5232 timeout : options . timeLimit ,
5333 } ;
5434
@@ -59,10 +39,8 @@ export function hengSpawn(
5939 options . stdio . push ( "pipe" ) ;
6040 basicOption . stdio = options . stdio ;
6141
62- const subProcess = loggedSpawn ( optionSetedSpawn ( spawn , basicOption ) ) (
63- command ,
64- args
65- ) ;
42+ logger . info ( `${ command } ${ args . join ( " " ) } ` ) ;
43+ const subProcess = spawn ( command , args , basicOption ) ;
6644 return {
6745 ...( subProcess as MeteredChildProcess ) ,
6846 result : new Promise ( ( resolve , reject ) => {
0 commit comments