Solve the checked issue

Signed-off-by: xdmal <maxiaodong16@huawei.com>
This commit is contained in:
xdmal
2022-03-09 16:14:50 +08:00
parent b4295580ab
commit 9e0359a626
14 changed files with 131 additions and 131 deletions
+4 -5
View File
@@ -114,7 +114,7 @@ gid(){
3.euid()
```
euid(){
var ans = Process.euid;
var and = Process.euid;
}
```
4.egid()
@@ -357,10 +357,9 @@ getSystemConfig(){
var ansu = Process.getSystemConfig(_SC_ARG_MAX)
}
```
## Related warehouse
[js_sys_module](base/compileruntime/js_sys_module/readme.md)
[js_sys_module subsystem](https://gitee.com/OHOS_STD/js_sys_module)
### License
[base/compileruntime/js_sys_module/](base/compileruntime/js_sys_module-readme.md)
SYS is available under [Mozilla license](https://www.mozilla.org/en-US/MPL/), and the documentation is detailed in [documentation](https://gitee.com/openharmony/js_sys_module/blob/master/mozilla_docs.txt). See [LICENSE](https://gitee.com/openharmony/js_sys_module/blob/master/LICENSE) for the full license text.
+94 -94
View File
@@ -1,104 +1,104 @@
# js_sys_module Subsystems/Components
# js_sys_module子系统/组件
- [Introduction](#Introduction)
- [Directory](#Directory)
- [Description](#Description)
- [Interface description](#Interface description)
- [Interface instructions](#Interface instructions)
- [简介](#简介)
- [目录](#目录)
- [说明](#说明)
- [接口说明](#接口说明)
- [使用说明](#使用说明)
- [Related warehouse](#Related warehouse])
- [相关仓](#相关仓])
## Introduction
Process is mainly used to obtain the relevant ID of the process, obtain and modify the working directory of the process, exit and close the process. The childprocess object can be used to create a new process. The main process can obtain the standard input and output of the child process, send signals and close the child process.
## Directory
## 简介
进程主要用于获取进程的相关ID,获取和修改进程的工作目录,退出和关闭进程。 childprocess 对象可用于创建新进程。 主进程可以获取子进程的标准输入输出,发送信号,关闭子进程。
## 目录
```
base/compileruntime/js_sys_module/
├── Class:PROCESS # class of PROCESS
├── Uid # attribute of Uid
├── Gid # attribute of Gid
├── EUid # attribute of EUid
├── EGid # attribute of EGid
├── Groups # attribute of Groups
├── Pid # attribute of Pid
├── Ppid # attribute of Ppid
├── chdir() # method of chdir
├── uptime() # method of uptime
├── kill() # method of kill
├── abort() # method of abort
├── on() # method of on
├── tid # method of tid
├── getStartRealtime() # method of getStartRealtime
├── getAvailableCores() # method of getAvailableCores
├── getPastCputime() # method of getPastCputime
├── isIsolatedProcess() # method of isIsolatedProcess
├── is64Bit() # method of is64Bit
├── isAppUid() # method of isAppUid
├── getUidForName() # method of getUidForName
├── getThreadPriority() # method of getThreadPriority
├── getSystemConfig() # method of getSystemConfig
├── getEnvironmentVar() # method of getEnvironmentVar
├── exit() # method of exit
├── cwd() # method of cwd
├── off() # method of off
├── runCmd() # method of runCmd
└─── Class:CHILDPROCESS # class of CHILDPROCESS
├── close() # method of close
├── kill() # method of kill
├── getOutput() # method of getOutput
├── getErrorOutput() # method of getErrorOutput
├── wait() # method of wait
├── killed # attribute of killed
├── pid # attribute of pid
├── ppid # attribute of ppid
└── exitCode # attribute of exitCode
├── Class:PROCESS # PROCESS
├── Uid # Uid属性
├── Gid # Gid属性
├── EUid # EUid属性
├── EGid # EGid属性
├── Groups # Groups属性
├── Pid # Pid属性
├── Ppid # Ppid属性
├── chdir() # chdir方法
├── uptime() # uptime方法
├── kill() # kill方法
├── abort() # abort方法
├── on() # on方法
├── tid # tid方法
├── getStartRealtime() # getStartRealtime方法
├── getAvailableCores() # getAvailableCores方法
├── getPastCputime() # getPastCputime方法
├── isIsolatedProcess() # isIsolatedProcess方法
├── is64Bit() # is64Bit方法
├── isAppUid() # isAppUid方法
├── getUidForName() # getUidForName方法
├── getThreadPriority() # getThreadPriority方法
├── getSystemConfig() # getSystemConfig方法
├── getEnvironmentVar() # getEnvironmentVar方法
├── exit() # exit方法
├── cwd() # cwd方法
├── off() # off方法
├── runCmd() # runCmd方法
└─── Class:CHILDPROCESS # class of CHILDPROCESS
├── close() # close方法
├── kill() # kill方法
├── getOutput() # getOutput方法
├── getErrorOutput() # getErrorOutput方法
├── wait() # wait方法
├── killed # killed属性
├── pid # pid属性
├── ppid # ppid属性
└── exitCode # exitCode属性
```
## Description
## 说明
### Interface description
| Interface name | description |
### 接口说明
| 接口名 | 说明 |
| -------- | -------- |
| const uid :number | returns the digital user ID of the process. |
| const gid :number | returns the numeric group ID of the process. |
| const euid :number | returns the numeric valid user identity of the process. |
| const egid :number | returns the numeric valid group ID of the node.js process. |
| const groups :number[] | returns an array with supplementary group ID. |
| const pid :number | returns the PID of the process. |
| const ppid :number | returns the PID of the parent process of the current process. |
| chdir(dir:string) :void | change the current working directory of the node.js process. |
| uptime() :number | returns the number of seconds the current system has been running. |
| Kill(pid:number, signal:number) :boolean | send the signal to the identified process PID, and true means the sending is successful. |
| abort() :void | cause the node.js process to exit immediately and generate a core file. |
| on(type:string ,listener:EventListener) :void | used to store events triggered by users. |
| exit(code:number):void | cause the node.js process to exit immediately. |
| cwd():string | returns the current working directory of the node.js process. |
| off(type: string): boolean | clear the events stored by the user. True means the clearing is successful. |
| runCmd(command: string, options?: { timeout : number, killSignal : number \| string, maxBuffer : number }): ChildProcess |through runcmd, you can fork a new process to run a shell and return the childprocess object. The first parameter command refers to the shell to be run, and the second parameter options refers to some running parameters of the child process. These parameters mainly refer to timeout, killsignal and maxbuffer. If timeout is set, the child process will send a signal killsignal after timeout is exceeded. Maxbuffer is used to limit the maximum stdout and stderr sizes that can be received. |
| wait() Promise\<number> | is used to wait for the child process to run and return the promise object, whose value is the exit code of the child process. |
| getOutput(): Promise\<Uint8Array> | used to get the standard output of the child process. |
| getErrorOutput(): Promise\<Uint8Array> | used to get the standard error output of the child process. |
| const tid:number | Returns the TID of the process. |
| getStartRealtime() :number | Gets the real time elapsed (in milliseconds) from system startup to process startup. |
| getAvailableCores() :number[] | Gets the CPU kernel available to the current process on the multi-core device. |
| getPastCputime() :number | Gets the CPU time (in milliseconds) from the start of the process to the current time. |
| isIsolatedProcess(): boolean | Check if the process is quarantined. |
| is64Bit(): boolean | Check whether the process is running in a 64 bit environment. |
| isAppUid(v:number): boolean | Checks whether the specified uid belongs to a specific application. |
| getUidForName(v:string): number | Obtain the user group ID to which the user belongs according to the user name |
| getThreadPriority(v:number): number | Gets the thread priority based on the specified TID. |
| getSystemConfig(name:number): number | Gets the configuration of the system according to the specified system configuration name. |
| getEnvironmentVar(name:string): string | Obtain the corresponding value according to the name of the environment variable. |
| close(): void | used to close the running child process. |
| kill(signal: number \| string): void | used to send signals to child processes. |
| readonly killed: boolean | indicates whether the signal is sent successfully, and true indicates that the signal is sent successfully. |
| readonly exitCode: number | indicates the exit code of the child process. |
| readonly pid: number | represents the child process ID. |
| readonly ppid: number | represents the main process ID. |
| const uid :number | 返回进程的数字用户 ID。 |
| const gid :number | 返回进程的数字组 ID。 |
| const euid :number | 返回进程的数字有效用户身份。 |
| const egid :number | 返回 node.js 进程的数字有效组 ID。 |
| const groups :number[] | 返回具有补充组 ID 的数组。 |
| const pid :number | 返回进程的PID。 |
| const ppid :number | 返回当前进程的父进程的PID。 |
| chdir(dir:string) :void | 更改 node.js 进程的当前工作目录。 |
| uptime() :number | 返回当前系统已经运行的秒数。 |
| Kill(pid:number, signal:number) :boolean | 将信号发送到识别的进程PID,true表示发送成功。 |
| abort() :void | 导致 node.js 进程立即退出并生成核心文件。 |
| on(type:string ,listener:EventListener) :void | 用于存储用户触发的事件。 |
| exit(code:number):void | 导致 node.js 进程立即退出。 |
| cwd():string | 返回 node.js 进程的当前工作目录。 |
| off(type: string): boolean | 清除用户存储的事件。 True 表示清算成功。 |
| runCmd(command: string, options?: { timeout : number, killSignal : number \| string, maxBuffer : number }): ChildProcess |通过runcmd,你可以fork一个新进程来运行一个shell并返回childprocess对象。 第一个参数command指的是要运行的shell,第二个参数options指的是子进程的一些运行参数。 这些参数主要是指 timeoutkillsignal maxbuffer。 如果设置了timeout,则子进程会在超时后发送killsignal信号。 Maxbuffer 用于限制可以接收的最大 stdout stderr 大小。 |
| wait() Promise\<number> | 用于等待子进程运行并返回promise对象,其值为子进程的退出码。 |
| getOutput(): Promise\<Uint8Array> | 用于获取子进程的标准输出。 |
| getErrorOutput(): Promise\<Uint8Array> | 用于获取子进程的标准错误输出。 |
| const tid:number | 返回进程的 TID。 |
| getStartRealtime() :number | 获取从系统启动到进程启动所经过的实时时间(以毫秒为单位)。 |
| getAvailableCores() :number[] | 获取多核设备上当前进程可用的 CPU 内核。 |
| getPastCputime() :number | 获取从进程开始到当前时间的 CPU 时间(以毫秒为单位)。 |
| isIsolatedProcess(): boolean | 检查进程是否被隔离。 |
| is64Bit(): boolean | 检查进程是否在 64 位环境中运行。 |
| isAppUid(v:number): boolean | 检查指定的 uid 是否属于特定应用程序。 |
| getUidForName(v:string): number | 根据用户名获取用户所属的用户组ID |
| getThreadPriority(v:number): number | 根据指定的 TID 获取线程优先级。 |
| getSystemConfig(name:number): number | 根据指定的系统配置名称获取系统的配置。 |
| getEnvironmentVar(name:string): string | 根据环境变量的名称获取对应的值。 |
| close(): void | 用于关闭正在运行的子进程。 |
| kill(signal: number \| string): void | 用于向子进程发送信号。 |
| readonly killed: boolean | 表示信号是否发送成功,true表示信号发送成功。 |
| readonly exitCode: number | 表示子进程的退出代码。 |
| readonly pid: number | 表示子进程ID |
| readonly ppid: number | 代表主进程ID |
### Interface instructions
### 使用说明
Example of using interface
各接口使用方法如下
1.uid()
```
uid(){
@@ -114,7 +114,7 @@ gid(){
3.euid()
```
euid(){
var ans = Process.euid;
var and = Process.euid;
}
```
4.egid()
@@ -358,9 +358,9 @@ getSystemConfig(){
}
```
## 相关仓
[js_sys_module](base/compileruntime/js_sys_module/readme.md)
## Related warehouse
### 许可证
[js_sys_module subsystem](https://gitee.com/OHOS_STD/js_sys_module)
[base/compileruntime/js_sys_module/](base/compileruntime/js_sys_module-readme.md)
SYS在[Mozilla许可证](https://www.mozilla.org/en-US/MPL/)下可用,说明文档详见[说明文档](https://gitee.com/openharmony/js_sys_module/blob/master/mozilla_docs.txt)。有关完整的许可证文本,有关完整的许可证文本,请参见[许可证](https://gitee.com/openharmony/js_sys_module/blob/master/LICENSE)
+1 -1
View File
@@ -1,4 +1,4 @@
# Copyright (c) 2021 Huawei Device Co., Ltd.
# Copyright (c) 2022 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
+9 -8
View File
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -71,14 +71,15 @@ namespace OHOS::Js_sys_module::Dfx {
napi_get_cb_info(env, info, &argc, nullptr, nullptr, nullptr);
NAPI_ASSERT(env, argc <= requireArgc, "Wrong number of arguments");
napi_value *argv = nullptr;
argv = new napi_value[argc];
NAPI_ASSERT(env, argc > 0, "argc == 0");
argv = new napi_value[argc + 1];
if (memset_s(argv, argc + 1, 0, argc + 1) != 0) {
HILOG_ERROR("argv memset error");
delete []argv;
argv = nullptr;
return nullptr;
if (argc > 0) {
argv = new napi_value[argc + 1];
if (memset_s(argv, argc + 1, 0, argc + 1) != 0) {
HILOG_ERROR("argv memset error");
delete []argv;
argv = nullptr;
return nullptr;
}
}
napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr);
double timeInterval = 0;
+1 -1
View File
@@ -1,4 +1,4 @@
# Copyright (c) 2021 Huawei Device Co., Ltd.
# Copyright (c) 2022 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
+5 -5
View File
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -80,7 +80,7 @@ namespace OHOS::Js_sys_module::Process {
}
std::string strCommnd = RequireStrValue(command);
pid_t pid = fork();
if (pid == 0) {
if (!pid) {
close(stdErrFd_[0]);
close(stdOutFd_[0]);
dup2(stdOutFd_[1], 1);
@@ -255,7 +255,7 @@ namespace OHOS::Js_sys_module::Process {
HILOG_ERROR("stdOut maxBuff kill signal failed");
}
}
if (memset_s(childStdout, sizeof(childStdout), '\0', MAXSIZE) != 0) {
if (memset_s(childStdout, sizeof(childStdout), '\0', MAXSIZE) != EOK) {
HILOG_ERROR("getOutput memset_s failed");
return;
}
@@ -289,7 +289,7 @@ namespace OHOS::Js_sys_module::Process {
HILOG_ERROR("stdErr maxBuff kill signal failed");
}
}
if (memset_s(childStderr, sizeof(childStderr), '\0', MAXSIZE) != 0) {
if (memset_s(childStderr, sizeof(childStderr), '\0', MAXSIZE) != EOK) {
HILOG_ERROR("getOutput memset_s failed");
return;
}
@@ -341,7 +341,7 @@ namespace OHOS::Js_sys_module::Process {
void ChildProcess::Close()
{
int32_t status = 0;
if (isWait_ && (waitpid(optionsInfo_->pid, &status, WNOHANG) == 0) && isNeedRun_) {
if (isWait_ && !(waitpid(optionsInfo_->pid, &status, WNOHANG)) && isNeedRun_) {
if (!kill(optionsInfo_->pid, SIGKILL)) {
waitpid(optionsInfo_->pid, &status, 0);
isWait_ = false;
+1 -1
View File
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
+10 -10
View File
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -94,8 +94,8 @@ namespace OHOS::Js_sys_module::Process {
}
std::vector<uint32_t> array;
for (auto iter = pgrous.begin(); iter != pgrous.end(); iter++) {
auto recive = static_cast<uint32_t>(*iter);
array.push_back(recive);
auto receive = static_cast<uint32_t>(*iter);
array.push_back(receive);
}
NAPI_CALL(env_, napi_create_array(env_, &result));
size_t len = array.size();
@@ -130,7 +130,7 @@ namespace OHOS::Js_sys_module::Process {
char* path = nullptr;
if (prolen > 0) {
path = new char[prolen + 1];
if (memset_s(path, prolen + 1, '\0', prolen + 1) != 0) {
if (memset_s(path, prolen + 1, '\0', prolen + 1) != EOK) {
napi_throw_error(env_, "-1", "chdir path memset_s failed");
}
} else {
@@ -156,7 +156,7 @@ namespace OHOS::Js_sys_module::Process {
napi_get_value_int32(env_, signal, &sig);
uv_pid_t ownPid = uv_os_getpid();
// 64:The maximum valid signal value is 64.
if (sig > 64 && (pid == 0 || pid == -1 || pid == ownPid || pid == -ownPid)) {
if (sig > 64 && (!pid || pid == -1 || pid == ownPid || pid == -ownPid)) {
napi_throw_error(env_, "0", "process exit");
}
bool flag = false;
@@ -252,7 +252,7 @@ namespace OHOS::Js_sys_module::Process {
NAPI_CALL(env_, napi_get_value_string_utf8(env_, str, buffer, 0, &bufferSize));
NAPI_ASSERT(env_, bufferSize > 0, "bufferSize == 0");
buffer = new char[bufferSize + 1];
if (memset_s(buffer, bufferSize + 1, 0, bufferSize + 1) != 0) {
if (memset_s(buffer, bufferSize + 1, 0, bufferSize + 1) != EOK) {
HILOG_ERROR("buffer memset error");
delete []buffer;
return nullptr;
@@ -393,7 +393,7 @@ namespace OHOS::Js_sys_module::Process {
napi_value result = nullptr;
napi_get_value_int32(env_, tid, &proTid);
int32_t pri = getpriority(PRIO_PROCESS, proTid);
if (errno != 0) {
if (errno) {
napi_throw_error(env_, "-1", "Invalid tid");
}
napi_create_int32(env_, pri, &result);
@@ -406,11 +406,11 @@ namespace OHOS::Js_sys_module::Process {
struct timespec timessys = {0, 0};
napi_value result = nullptr;
auto res = clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &timespro);
if (res != 0) {
if (res) {
return 0;
}
auto res1 = clock_gettime(CLOCK_MONOTONIC, &timessys);
if (res1 != 0) {
if (res1) {
return 0;
}
int whenpro = ConvertTime(timespro.tv_sec, timespro.tv_nsec);
@@ -430,7 +430,7 @@ namespace OHOS::Js_sys_module::Process {
struct timespec times = {0, 0};
napi_value result = nullptr;
auto res = clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &times);
if (res != 0) {
if (res) {
return 0;
}
int when = ConvertTime(times.tv_sec, times.tv_nsec);
+1 -1
View File
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
+1 -1
View File
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
+1 -1
View File
@@ -1,4 +1,4 @@
# Copyright (c) 2021 Huawei Device Co., Ltd.
# Copyright (c) 2022 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
+1 -1
View File
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
+1 -1
View File
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
+1 -1
View File
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at