From c4854e6560ff552f1333ffbd6f9efb0330db62fa Mon Sep 17 00:00:00 2001 From: Gloria Date: Wed, 15 Mar 2023 09:15:10 +0800 Subject: [PATCH] Update docs against 15749 Signed-off-by: wusongqing --- .../reference/apis/js-apis-process.md | 314 ------------------ .../reference/apis/js-apis-util.md | 2 +- 2 files changed, 1 insertion(+), 315 deletions(-) diff --git a/en/application-dev/reference/apis/js-apis-process.md b/en/application-dev/reference/apis/js-apis-process.md index 02dbfe617a..e50764d1b1 100755 --- a/en/application-dev/reference/apis/js-apis-process.md +++ b/en/application-dev/reference/apis/js-apis-process.md @@ -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.
**System API**: This is a system API.
It is used only to test applications.| -| euid | number | Yes| No| Effective user identifier (EUID) of the process.
**System API**: This is a system API.
It is used only to test applications.| -| gid | number | Yes| No| Group identifier (GID) of the process.
**System API**: This is a system API.
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.
**System API**: This is a system API.
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.
**System API**: This is a system API.
It is used only to test applications.| | tid8+ | 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 \| 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.
**System API**: This is a system API.
It is used only to test applications.| -| ppid | number | Yes| No| PPID of the child process.
**System API**: This is a system API.
It is used only to test applications.| -| exitCode | number | Yes| No| Exit code of the child process.
**System API**: This is a system API.
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.
**System API**: This is a system API.
It is used only to test applications.| - - -### wait - -wait(): Promise<number> - -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<number> | 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<Uint8Array> - -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<Uint8Array> | 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<Uint8Array> - -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<Uint8Array> | 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 \| string | Yes| Number or string to send.| - -**Example** - -```js -let child = process.runCmd('sleep 5; ls'); -child.kill(9); -``` diff --git a/en/application-dev/reference/apis/js-apis-util.md b/en/application-dev/reference/apis/js-apis-util.md index ea60b649da..16a80bd27e 100755 --- a/en/application-dev/reference/apis/js-apis-util.md +++ b/en/application-dev/reference/apis/js-apis-util.md @@ -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); }); -- GitLab