• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2* Copyright (c) 2021 Huawei Device Co., Ltd.
3* Licensed under the Apache License, Version 2.0 (the "License");
4* you may not use this file except in compliance with the License.
5* You may obtain a copy of the License at
6*
7*     http://www.apache.org/licenses/LICENSE-2.0
8*
9* Unless required by applicable law or agreed to in writing, software
10* distributed under the License is distributed on an "AS IS" BASIS,
11* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12* See the License for the specific language governing permissions and
13* limitations under the License.
14*/
15
16declare namespace process {
17
18    export interface ChildProcess {
19        readonly pid: number;
20        readonly ppid: number;
21        readonly exitCode: number;
22        readonly killed: boolean;
23
24        wait(): Promise<number>;
25        /**
26        * Buffer the stdout until EOF and return it as 'Uint8Array'
27        */
28        getOutput(): Promise<Uint8Array>;
29        /**
30        * Buffer the stderr until EOF and return it as 'Uint8Array'
31        */
32        getErrorOutput(): Promise<Uint8Array>;
33        /**
34        * close the target process
35        */
36        close(): void;
37        /**
38        * send a signal to process
39        */
40        kill(signo: number): void;
41    }
42    /**
43    * spawns a new ChildProcess to run the command
44    */
45    function runCmd(command: string, options?: RunOptions): ChildProcess;
46
47    function getPid(): number;
48    function getPpid(): number;
49
50    /**
51    *abort current process
52    *@return void
53    */
54    function abort(): void;
55
56    function on(type: string, listener: EventListener): void;
57    function exit(code:number): void;
58
59    /**
60    *get current work directory;
61    */
62    function cwd(): string;
63
64    /**
65    *change current  directory
66    *@param dir
67    */
68    function chdir(dir: string): void;
69
70    function getEgid(): number;
71    function getEuid(): number;
72
73    function getGid(): number;
74    function getUid(): number;
75    function uptime(): number;
76
77    function getGroups(): number[];
78    function kill(signal: number, pid: number): boolean;
79    function off(type: string): boolean;
80}
81export default process;