未验证 提交 d3e3376b 编写于 作者: O openharmony_ci 提交者: Gitee

!16076 翻译完成:15749 Delete test interface data in process module

Merge pull request !16076 from wusongqing/TR15749
......@@ -18,13 +18,8 @@ import process from '@ohos.process';
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| egid | number | Yes| No| Effective group identifier (EGID) of the process.<br>**System API**: This is a system API.<br>It is used only to test applications.|
| euid | number | Yes| No| Effective user identifier (EUID) of the process.<br>**System API**: This is a system API.<br>It is used only to test applications.|
| gid | number | Yes| No| Group identifier (GID) of the process.<br>**System API**: This is a system API.<br>It is used only to test applications.|
| uid | number | Yes| No| User identifier (UID) of the process.|
| groups | number[] | Yes| No| Array with supplementary group IDs.<br>**System API**: This is a system API.<br>It is used only to test applications.|
| pid | number | Yes| No| Process ID (PID) of the process.|
| ppid | number | Yes| No| Parent process ID (PPID) of the process.<br>**System API**: This is a system API.<br>It is used only to test applications.|
| tid<sup>8+</sup> | number | Yes| No| Thread ID (TID) of the thread.|
......@@ -120,50 +115,6 @@ let result = process.getPastCpuTime() ;
```
## process.runCmd
runCmd(command: string, options?: { timeout?: number, killSignal?: number | string, maxBuffer?: number }): ChildProcess
Forks a new process to run a shell command and returns the **ChildProcess** object.
**System API**: This is a system API.
It is used only to test applications.
**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| command | string | Yes| Shell command to run.|
| options | Object | No| Related parameters.|
**Table 1** options
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| timeout | number | No| Maximum running time (in milliseconds) of the child process. When the running time of the child process exceeds the value of this parameter, the parent process sends a **killSignal** to the child process to terminate it. The default value is **0**.|
| killSignal | number&nbsp;\|&nbsp;string | No| Signal sent to the child process when the running time of a child process exceeds the timeout period. The default value is **SIGTERM**.|
| maxBuffer | number | No| Maximum buffer size for the standard input and output of the child process. When the size is exceeded, the child process will be terminated. The default value is **1024 \* 1024**.|
**Return value**
| Type| Description|
| -------- | -------- |
| [ChildProcess](#childprocess) | **ChildProcess** object.|
**Example**
```js
let child = process.runCmd('ls', { maxBuffer : 2 });
let result = child.wait();
child.getOutput.then(val=>{
console.log("child.getOutput = " + val);
})
```
## process.abort
abort(): void
......@@ -179,118 +130,6 @@ process.abort();
```
## process.on
on(type: string, listener: EventListener): void
Stores the events triggered by the user.
**System API**: This is a system API.
It is used only to test applications.
**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Type of the events to store. |
| listener | [EventListener](#eventlistener) | Yes| Callback invoked to return the event.|
**Example**
```js
process.on("data", (e)=>{
console.log("data callback");
})
```
## process.off
off(type: string): boolean
Deletes the event stored by the user.
**System API**: This is a system API.
It is used only to test applications.
**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Type of the event to delete.|
**Return value**
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the event is deleted; returns **false** otherwise.|
**Example**
```js
process.on("data", (e)=>{
console.log("data callback");
})
let result = process.off("data");
```
## process.cwd
cwd(): string
Obtains the working directory of this process.
**System API**: This is a system API.
It is used only to test applications.
**System capability**: SystemCapability.Utils.Lang
**Return value**
| Type| Description|
| -------- | -------- |
| string| Working directory obtained.|
**Example**
```js
let path = process.cwd();
```
## process.chdir
chdir(dir: string): void
Changes the working directory of this process.
**System API**: This is a system API.
It is used only to test applications.
**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| dir | string | Yes| Path|
**Example**
```js
process.chdir('/system');
```
## process.uptime
uptime(): number
......@@ -729,156 +568,3 @@ let pro = new process.ProcessManager();
let pres = process.pid;
let result = pro.kill(28, pres);
```
## ChildProcess
The **ChildProcess** object is a new child process and can be obtained by calling [process.runCmd](#processruncmd). The main process can obtain the standard input and output of the child process, send signals to the child process, and close the child process.
**System API**: This is a system API.
### Attributes
**System API**: This is a system API.
**System capability**: SystemCapability.Utils.Lang
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| pid | number | Yes| No| PID of the child process.<br>**System API**: This is a system API.<br>It is used only to test applications.|
| ppid | number | Yes| No| PPID of the child process.<br>**System API**: This is a system API.<br>It is used only to test applications.|
| exitCode | number | Yes| No| Exit code of the child process.<br>**System API**: This is a system API.<br>It is used only to test applications.|
| killed | boolean | Yes| No| Whether the parent process successfully sends a signal to the child process to terminate it.<br>**System API**: This is a system API.<br>It is used only to test applications.|
### wait
wait(): Promise&lt;number&gt;
Waits until the child process ends. This method uses a promise to return the exit code of the child process.
**System API**: This is a system API.
It is used only to test applications.
**System capability**: SystemCapability.Utils.Lang
**Return value**
| Type| Description|
| -------- | -------- |
| Promise&lt;number&gt; | Promise used to return the exit code of the child process.|
**Example**
```js
let child = process.runCmd('ls');
let result = child.wait();
result.then(val=>{
console.log("result = " + val);
})
```
### getOutput
getOutput(): Promise&lt;Uint8Array&gt;
Obtains the standard output of the child process.
**System API**: This is a system API.
It is used only to test applications.
**System capability**: SystemCapability.Utils.Lang
**Return value**
| Type| Description|
| -------- | -------- |
| Promise&lt;Uint8Array&gt; | Promise used to return the standard output in a Uint8Array.|
**Example**
```js
let child = process.runCmd('ls');
let result = child.wait();
child.getOutput().then(val=>{
console.log("child.getOutput = " + val);
})
```
### getErrorOutput
getErrorOutput(): Promise&lt;Uint8Array&gt;
Obtains the standard error output of the child process.
**System API**: This is a system API.
It is used only to test applications.
**System capability**: SystemCapability.Utils.Lang
**Return value**
| Type| Description|
| -------- | -------- |
| Promise&lt;Uint8Array&gt; | Promise used to return the standard error output in a Uint8Array.|
**Example**
```js
let child = process.runCmd('madir test.text');
let result = child.wait();
child.getErrorOutput().then(val=>{
console.log("child.getErrorOutput= " + val);
})
```
### close
close(): void
Closes the child process in running.
**System API**: This is a system API.
It is used only to test applications.
**System capability**: SystemCapability.Utils.Lang
**Example**
```js
let child = process.runCmd('sleep 5; ls');
child.close();
```
### kill
kill(signal: number | string): void
Sends a signal to the specified child process to terminate it.
**System API**: This is a system API.
It is used only to test applications.
**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| signal | number&nbsp;\|&nbsp;string | Yes| Number or string to send.|
**Example**
```js
let child = process.runCmd('sleep 5; ls');
child.kill(9);
```
......@@ -110,7 +110,7 @@ async function fn() {
return 'hello world';
}
let cb = util.callbackWrapper(fn);
cb((err, ret) => {
cb(1, (err, ret) => {
if (err) throw err;
console.log(ret);
});
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册