1/* 2 * Copyright (c) 2021-2022 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 16/** 17 * @file 18 * @kit ArkTS 19 */ 20 21/** 22 * The process is mainly used to obtain the relevant ID of the process, obtain and modify 23 * the working directory of the process, exit and close the process. 24 * 25 * @namespace process 26 * @syscap SystemCapability.Utils.Lang 27 * @since 7 28 */ 29/** 30 * The process is mainly used to obtain the relevant ID of the process, obtain and modify 31 * the working directory of the process, exit and close the process. 32 * 33 * @namespace process 34 * @syscap SystemCapability.Utils.Lang 35 * @crossplatform 36 * @since 10 37 */ 38/** 39 * The process is mainly used to obtain the relevant ID of the process, obtain and modify 40 * the working directory of the process, exit and close the process. 41 * 42 * @namespace process 43 * @syscap SystemCapability.Utils.Lang 44 * @crossplatform 45 * @atomicservice 46 * @since 11 47 */ 48declare namespace process { 49 /** 50 * The childprocess object can be used to create a new process. 51 * 52 * @typedef ChildProcess 53 * @syscap SystemCapability.Utils.Lang 54 * @systemapi Hide this for inner system use 55 * @since 7 56 * @test 57 */ 58 export interface ChildProcess { 59 /** 60 * Return pid is the pid of the current process 61 * 62 * @type { number } 63 * @readonly 64 * @syscap SystemCapability.Utils.Lang 65 * @systemapi Hide this for inner system use 66 * @since 7 67 * @test 68 */ 69 readonly pid: number; 70 71 /** 72 * Return ppid is the pid of the current child process 73 * 74 * @type { number } 75 * @readonly 76 * @syscap SystemCapability.Utils.Lang 77 * @systemapi Hide this for inner system use 78 * @since 7 79 * @test 80 */ 81 readonly ppid: number; 82 83 /** 84 * Return exitCode is the exit code of the current child process 85 * 86 * @type { number } 87 * @readonly 88 * @syscap SystemCapability.Utils.Lang 89 * @systemapi Hide this for inner system use 90 * @since 7 91 * @test 92 */ 93 readonly exitCode: number; 94 95 /** 96 * Return boolean is whether the current process signal is sent successfully 97 * 98 * @type { boolean } 99 * @readonly 100 * @syscap SystemCapability.Utils.Lang 101 * @systemapi Hide this for inner system use 102 * @since 7 103 * @test 104 */ 105 readonly killed: boolean; 106 107 /** 108 * Return 'number' is the target process exit code 109 * 110 * @returns { Promise<number> } Return the target process exit code. 111 * @syscap SystemCapability.Utils.Lang 112 * @systemapi Hide this for inner system use 113 * @since 7 114 * @test 115 */ 116 wait(): Promise<number>; 117 118 /** 119 * Return it as 'Uint8Array' of the stdout until EOF 120 * 121 * @returns { Promise<Uint8Array> } Return subprocess standard output. 122 * @syscap SystemCapability.Utils.Lang 123 * @systemapi Hide this for inner system use 124 * @since 7 125 * @test 126 */ 127 getOutput(): Promise<Uint8Array>; 128 129 /** 130 * Return it as 'Uint8Array of the stderr until EOF 131 * 132 * @returns { Promise<Uint8Array> } Return subprocess standard error output. 133 * @syscap SystemCapability.Utils.Lang 134 * @systemapi Hide this for inner system use 135 * @since 7 136 * @test 137 */ 138 getErrorOutput(): Promise<Uint8Array>; 139 140 /** 141 * Close the target process 142 * 143 * @syscap SystemCapability.Utils.Lang 144 * @systemapi Hide this for inner system use 145 * @since 7 146 * @test 147 */ 148 close(): void; 149 150 /** 151 * Send a signal to process 152 * 153 * @param { number | string } signal - Number or string represents the signal sent. 154 * @syscap SystemCapability.Utils.Lang 155 * @systemapi Hide this for inner system use 156 * @since 7 157 * @test 158 */ 159 kill(signal: number | string): void; 160 } 161 162 /** 163 * Process is mainly used to obtain the relevant ID of the process, obtain and modify the 164 * working directory of the process, exit and close the process. 165 * 166 * @syscap SystemCapability.Utils.Lang 167 * @since 9 168 * @name ProcessManager 169 */ 170 /** 171 * Process is mainly used to obtain the relevant ID of the process, obtain and modify the 172 * working directory of the process, exit and close the process. 173 * 174 * @syscap SystemCapability.Utils.Lang 175 * @crossplatform 176 * @since 10 177 * @name ProcessManager 178 */ 179 /** 180 * Process is mainly used to obtain the relevant ID of the process, obtain and modify the 181 * working directory of the process, exit and close the process. 182 * 183 * @syscap SystemCapability.Utils.Lang 184 * @crossplatform 185 * @atomicservice 186 * @since 11 187 * @name ProcessManager 188 */ 189 export class ProcessManager { 190 /** 191 * Returns a boolean whether the specified uid belongs to a particular application. 192 * 193 * @param { number } v - An id. 194 * @returns { boolean } Return a boolean whether the specified uid belongs to a particular application. 195 * @throws { BusinessError } 401 - Parameter error. Possible causes: 196 * 1.Mandatory parameters are left unspecified; 197 * 2.Incorrect parameter types. 198 * @syscap SystemCapability.Utils.Lang 199 * @since 9 200 */ 201 /** 202 * Returns a boolean whether the specified uid belongs to a particular application. 203 * 204 * @param { number } v - An id. 205 * @returns { boolean } Return a boolean whether the specified uid belongs to a particular application. 206 * @throws { BusinessError } 401 - Parameter error. Possible causes: 207 * 1.Mandatory parameters are left unspecified; 208 * 2.Incorrect parameter types. 209 * @syscap SystemCapability.Utils.Lang 210 * @crossplatform 211 * @since 10 212 */ 213 /** 214 * Checks whether a UID belongs to this application. 215 * 216 * @param { number } v - UID. which can be obtained by running process.uid. 217 * @returns { boolean } Return a boolean whether the specified uid belongs to a particular application. 218 * @throws { BusinessError } 401 - Parameter error. Possible causes: 219 * 1.Mandatory parameters are left unspecified; 220 * 2.Incorrect parameter types. 221 * @syscap SystemCapability.Utils.Lang 222 * @crossplatform 223 * @atomicservice 224 * @since 11 225 */ 226 isAppUid(v: number): boolean; 227 228 /** 229 * Returns the uid based on the specified user name. 230 * 231 * @param { string } v - Process name. 232 * @returns { number } Return the uid based on the specified user name. 233 * @throws { BusinessError } 401 - Parameter error. Possible causes: 234 * 1.Mandatory parameters are left unspecified; 235 * 2.Incorrect parameter types. 236 * @syscap SystemCapability.Utils.Lang 237 * @since 9 238 */ 239 /** 240 * Returns the uid based on the specified user name. 241 * 242 * @param { string } v - Process name. 243 * @returns { number } Return the uid based on the specified user name. 244 * @throws { BusinessError } 401 - Parameter error. Possible causes: 245 * 1.Mandatory parameters are left unspecified; 246 * 2.Incorrect parameter types. 247 * @syscap SystemCapability.Utils.Lang 248 * @crossplatform 249 * @since 10 250 */ 251 /** 252 * Obtains the UID of a user from the user database of the system based on the specified user name. 253 * 254 * @param { string } v - User name. 255 * @returns { number } Return the uid based on the specified user name. 256 * @throws { BusinessError } 401 - Parameter error. Possible causes: 257 * 1.Mandatory parameters are left unspecified; 258 * 2.Incorrect parameter types. 259 * @syscap SystemCapability.Utils.Lang 260 * @crossplatform 261 * @atomicservice 262 * @since 11 263 */ 264 getUidForName(v: string): number; 265 266 /** 267 * Returns the thread priority based on the specified tid. 268 * 269 * @param { number } v - The tid of the process. 270 * @returns { number } Return the thread priority based on the specified tid. 271 * @throws { BusinessError } 401 - Parameter error. Possible causes: 272 * 1.Mandatory parameters are left unspecified; 273 * 2.Incorrect parameter types. 274 * @syscap SystemCapability.Utils.Lang 275 * @since 9 276 */ 277 /** 278 * Returns the thread priority based on the specified tid. 279 * 280 * @param { number } v - The tid of the process. 281 * @returns { number } Return the thread priority based on the specified tid. 282 * @throws { BusinessError } 401 - Parameter error. Possible causes: 283 * 1.Mandatory parameters are left unspecified; 284 * 2.Incorrect parameter types. 285 * @syscap SystemCapability.Utils.Lang 286 * @crossplatform 287 * @since 10 288 */ 289 /** 290 * Obtains the thread priority based on the specified TID. 291 * 292 * @param { number } v - TID. 293 * @returns { number } Return the thread priority based on the specified tid. 294 * @throws { BusinessError } 401 - Parameter error. Possible causes: 295 * 1.Mandatory parameters are left unspecified; 296 * 2.Incorrect parameter types. 297 * @syscap SystemCapability.Utils.Lang 298 * @crossplatform 299 * @atomicservice 300 * @since 11 301 */ 302 getThreadPriority(v: number): number; 303 304 /** 305 * Returns the system configuration at runtime. 306 * 307 * @param { number } name - Parameters defined by the system configuration. 308 * @returns { number } Return the system configuration at runtime. 309 * @throws { BusinessError } 401 - Parameter error. Possible causes: 310 * 1.Mandatory parameters are left unspecified; 311 * 2.Incorrect parameter types. 312 * @syscap SystemCapability.Utils.Lang 313 * @since 9 314 */ 315 /** 316 * Returns the system configuration at runtime. 317 * 318 * @param { number } name - Parameters defined by the system configuration. 319 * @returns { number } Return the system configuration at runtime. 320 * @throws { BusinessError } 401 - Parameter error. Possible causes: 321 * 1.Mandatory parameters are left unspecified; 322 * 2.Incorrect parameter types. 323 * @syscap SystemCapability.Utils.Lang 324 * @crossplatform 325 * @since 10 326 */ 327 /** 328 * Obtains the system configuration. 329 * 330 * @param { number } name - System configuration parameter name. 331 * @returns { number } Return the system configuration at runtime. 332 * @throws { BusinessError } 401 - Parameter error. Possible causes: 333 * 1.Mandatory parameters are left unspecified; 334 * 2.Incorrect parameter types. 335 * @syscap SystemCapability.Utils.Lang 336 * @crossplatform 337 * @atomicservice 338 * @since 11 339 */ 340 getSystemConfig(name: number): number; 341 342 /** 343 * Returns the system value for environment variables. 344 * 345 * @param { string } name - Parameters defined by the system environment variables. 346 * @returns { string } Return the system value for environment variables. 347 * @throws { BusinessError } 401 - Parameter error. Possible causes: 348 * 1.Mandatory parameters are left unspecified; 349 * 2.Incorrect parameter types. 350 * @syscap SystemCapability.Utils.Lang 351 * @since 9 352 */ 353 /** 354 * Returns the system value for environment variables. 355 * 356 * @param { string } name - Parameters defined by the system environment variables. 357 * @returns { string } Return the system value for environment variables. 358 * @throws { BusinessError } 401 - Parameter error. Possible causes: 359 * 1.Mandatory parameters are left unspecified; 360 * 2.Incorrect parameter types. 361 * @syscap SystemCapability.Utils.Lang 362 * @crossplatform 363 * @since 10 364 */ 365 /** 366 * Obtains the value of an environment variable. 367 * 368 * @param { string } name - Environment variable name. 369 * @returns { string } Return the system value for environment variables. 370 * @throws { BusinessError } 401 - Parameter error. Possible causes: 371 * 1.Mandatory parameters are left unspecified; 372 * 2.Incorrect parameter types. 373 * @syscap SystemCapability.Utils.Lang 374 * @crossplatform 375 * @atomicservice 376 * @since 11 377 */ 378 getEnvironmentVar(name: string): string; 379 380 /** 381 * Process exit 382 * 383 * @param { number } code - Process exit code. 384 * @throws { BusinessError } 401 - Parameter error. Possible causes: 385 * 1.Mandatory parameters are left unspecified; 386 * 2.Incorrect parameter types. 387 * @syscap SystemCapability.Utils.Lang 388 * @since 9 389 */ 390 /** 391 * Process exit 392 * 393 * @param { number } code - Process exit code. 394 * @throws { BusinessError } 401 - Parameter error. Possible causes: 395 * 1.Mandatory parameters are left unspecified; 396 * 2.Incorrect parameter types. 397 * @syscap SystemCapability.Utils.Lang 398 * @crossplatform 399 * @since 10 400 */ 401 /** 402 * Terminates this process. 403 * 404 * @param { number } code - Exit code of the process. 405 * @throws { BusinessError } 401 - Parameter error. Possible causes: 406 * 1.Mandatory parameters are left unspecified; 407 * 2.Incorrect parameter types. 408 * @syscap SystemCapability.Utils.Lang 409 * @crossplatform 410 * @atomicservice 411 * @since 11 412 */ 413 exit(code: number): void; 414 415 /** 416 * Return whether the signal was sent successfully 417 * 418 * @param { number } signal - Signal sent. 419 * @param { number } pid - Send signal to target pid. 420 * @returns { boolean } Return the result of the signal. 421 * @throws { BusinessError } 401 - Parameter error. Possible causes: 422 * 1.Mandatory parameters are left unspecified; 423 * 2.Incorrect parameter types. 424 * @syscap SystemCapability.Utils.Lang 425 * @since 9 426 */ 427 /** 428 * Return whether the signal was sent successfully 429 * 430 * @param { number } signal - Signal sent. 431 * @param { number } pid - Send signal to target pid. 432 * @returns { boolean } Return the result of the signal. 433 * @throws { BusinessError } 401 - Parameter error. Possible causes: 434 * 1.Mandatory parameters are left unspecified; 435 * 2.Incorrect parameter types. 436 * @syscap SystemCapability.Utils.Lang 437 * @crossplatform 438 * @since 10 439 */ 440 /** 441 * Sends a signal to the specified process to terminate it. 442 * 443 * @param { number } signal - Signal to send. 444 * @param { number } pid - PID of the process, to which the signal will be sent. 445 * @returns { boolean } Return the result of the signal. 446 * @throws { BusinessError } 401 - Parameter error. Possible causes: 447 * 1.Mandatory parameters are left unspecified; 448 * 2.Incorrect parameter types. 449 * @syscap SystemCapability.Utils.Lang 450 * @crossplatform 451 * @atomicservice 452 * @since 11 453 */ 454 kill(signal: number, pid: number): boolean; 455 } 456 457 /** 458 * Returns the numeric valid group ID of the process 459 * 460 * @syscap SystemCapability.Utils.Lang 461 * @systemapi Hide this for inner system use 462 * @since 7 463 * @test 464 */ 465 const egid: number; 466 467 /** 468 * Return the numeric valid user identity of the process 469 * 470 * @syscap SystemCapability.Utils.Lang 471 * @systemapi Hide this for inner system use 472 * @since 7 473 * @test 474 */ 475 const euid: number; 476 477 /** 478 * Returns the numeric group id of the process 479 * 480 * @syscap SystemCapability.Utils.Lang 481 * @systemapi Hide this for inner system use 482 * @since 7 483 * @test 484 */ 485 const gid: number; 486 487 /** 488 * Returns the digital user id of the process 489 * 490 * @syscap SystemCapability.Utils.Lang 491 * @since 7 492 */ 493 /** 494 * Returns the digital user id of the process 495 * 496 * @syscap SystemCapability.Utils.Lang 497 * @crossplatform 498 * @since 10 499 */ 500 /** 501 * Returns the digital user id of the process 502 * 503 * @syscap SystemCapability.Utils.Lang 504 * @crossplatform 505 * @atomicservice 506 * @since 11 507 */ 508 const uid: number; 509 510 /** 511 * Return an array with supplementary group id 512 * 513 * @syscap SystemCapability.Utils.Lang 514 * @systemapi Hide this for inner system use 515 * @since 7 516 * @test 517 */ 518 const groups: number[]; 519 520 /** 521 * Return pid is The pid of the current process 522 * 523 * @syscap SystemCapability.Utils.Lang 524 * @since 7 525 */ 526 /** 527 * Return pid is The pid of the current process 528 * 529 * @syscap SystemCapability.Utils.Lang 530 * @crossplatform 531 * @since 10 532 */ 533 /** 534 * Return pid is The pid of the current process 535 * 536 * @syscap SystemCapability.Utils.Lang 537 * @crossplatform 538 * @atomicservice 539 * @since 11 540 */ 541 const pid: number; 542 543 /** 544 * Return ppid is The pid of the current child process 545 * 546 * @syscap SystemCapability.Utils.Lang 547 * @systemapi Hide this for inner system use 548 * @since 7 549 * @test 550 */ 551 const ppid: number; 552 553 /** 554 * Returns the tid of the current thread. 555 * 556 * @syscap SystemCapability.Utils.Lang 557 * @since 8 558 */ 559 /** 560 * Returns the tid of the current thread. 561 * 562 * @syscap SystemCapability.Utils.Lang 563 * @crossplatform 564 * @since 10 565 */ 566 /** 567 * Returns the tid of the current thread. 568 * 569 * @syscap SystemCapability.Utils.Lang 570 * @crossplatform 571 * @atomicservice 572 * @since 11 573 */ 574 const tid: number; 575 576 /** 577 * Returns a boolean whether the process is isolated. 578 * 579 * @returns { boolean } Return boolean whether the process is isolated. 580 * @syscap SystemCapability.Utils.Lang 581 * @since 8 582 */ 583 /** 584 * Checks whether this process is isolated. 585 * 586 * @returns { boolean } Return boolean whether the process is isolated. 587 * @syscap SystemCapability.Utils.Lang 588 * @atomicservice 589 * @since 11 590 */ 591 function isIsolatedProcess(): boolean; 592 593 /** 594 * Returns a boolean whether the specified uid belongs to a particular application. 595 * 596 * @param { number } v - An id. 597 * @returns { boolean } Return a boolean whether the specified uid belongs to a particular application. 598 * @syscap SystemCapability.Utils.Lang 599 * @since 8 600 * @deprecated since 9 601 * @useinstead ohos.process.ProcessManager.isAppUid 602 */ 603 function isAppUid(v: number): boolean; 604 605 /** 606 * Returns a boolean whether the process is running in a 64-bit environment. 607 * 608 * @returns { boolean } Return a boolean whether the process is running in a 64-bit environment. 609 * @syscap SystemCapability.Utils.Lang 610 * @since 8 611 */ 612 /** 613 * Returns a boolean whether the process is running in a 64-bit environment. 614 * 615 * @returns { boolean } Return a boolean whether the process is running in a 64-bit environment. 616 * @syscap SystemCapability.Utils.Lang 617 * @crossplatform 618 * @since 10 619 */ 620 /** 621 * Checks whether this process is running in a 64-bit environment. 622 * 623 * @returns { boolean } Return a boolean whether the process is running in a 64-bit environment. 624 * @syscap SystemCapability.Utils.Lang 625 * @crossplatform 626 * @atomicservice 627 * @since 11 628 */ 629 function is64Bit(): boolean; 630 631 /** 632 * Returns the uid based on the specified user name. 633 * 634 * @param { string } v - Process name. 635 * @returns { number } Return the uid based on the specified user name. 636 * @syscap SystemCapability.Utils.Lang 637 * @since 8 638 * @deprecated since 9 639 * @useinstead ohos.process.ProcessManager.getUidForName 640 */ 641 function getUidForName(v: string): number; 642 643 /** 644 * Returns the thread priority based on the specified tid. 645 * 646 * @param { number } v - The tid of the process. 647 * @returns { number } Return the thread priority based on the specified tid. 648 * @syscap SystemCapability.Utils.Lang 649 * @since 8 650 * @deprecated since 9 651 * @useinstead ohos.process.ProcessManager.getThreadPriority 652 */ 653 function getThreadPriority(v: number): number; 654 655 /** 656 * Returns the elapsed real time (in milliseconds) taken from the start of the system to the start of the process. 657 * 658 * @returns { number } Return the start of the system to the start of the process. 659 * @syscap SystemCapability.Utils.Lang 660 * @since 8 661 */ 662 /** 663 * Returns the elapsed real time (in milliseconds) taken from the start of the system to the start of the process. 664 * 665 * @returns { number } Return the start of the system to the start of the process. 666 * @syscap SystemCapability.Utils.Lang 667 * @crossplatform 668 * @since 10 669 */ 670 /** 671 * Obtains the duration, in milliseconds, from the time the system starts to the time the process starts. 672 * 673 * @returns { number } Return the start of the system to the start of the process. 674 * @syscap SystemCapability.Utils.Lang 675 * @crossplatform 676 * @atomicservice 677 * @since 11 678 */ 679 function getStartRealtime(): number; 680 681 /** 682 * Returns the cpu time (in milliseconds) from the time when the process starts to the current time. 683 * 684 * @returns { number } Return the cpu time (in milliseconds) from the time when the process starts to the current time. 685 * @syscap SystemCapability.Utils.Lang 686 * @since 8 687 */ 688 /** 689 * Returns the cpu time (in milliseconds) from the time when the process starts to the current time. 690 * 691 * @returns { number } Return the cpu time (in milliseconds) from the time when the process starts to the current time. 692 * @syscap SystemCapability.Utils.Lang 693 * @crossplatform 694 * @since 10 695 */ 696 /** 697 * Obtains the CPU time (in milliseconds) from the time the process starts to the current time. 698 * 699 * @returns { number } Return the cpu time (in milliseconds) from the time when the process starts to the current time. 700 * @syscap SystemCapability.Utils.Lang 701 * @crossplatform 702 * @atomicservice 703 * @since 11 704 */ 705 function getPastCpuTime(): number; 706 707 /** 708 * Returns the system configuration at runtime. 709 * 710 * @param { number } name - Parameters defined by the system configuration. 711 * @returns { number } Return the system configuration at runtime. 712 * @syscap SystemCapability.Utils.Lang 713 * @since 8 714 * @deprecated since 9 715 * @useinstead ohos.process.ProcessManager.getSystemConfig 716 */ 717 function getSystemConfig(name: number): number; 718 719 /** 720 * Returns the system value for environment variables. 721 * 722 * @param { string } name - Parameters defined by the system environment variables. 723 * @returns { string } Return the system value for environment variables. 724 * @syscap SystemCapability.Utils.Lang 725 * @since 8 726 * @deprecated since 9 727 * @useinstead ohos.process.ProcessManager.getEnvironmentVar 728 */ 729 function getEnvironmentVar(name: string): string; 730 731 /** 732 * User Stored Events 733 * 734 * @syscap SystemCapability.Utils.Lang 735 * @since 7 736 */ 737 /** 738 * User Stored Events 739 * 740 * @syscap SystemCapability.Utils.Lang 741 * @crossplatform 742 * @since 10 743 */ 744 /** 745 * User Stored Events 746 * 747 * @syscap SystemCapability.Utils.Lang 748 * @crossplatform 749 * @atomicservice 750 * @since 11 751 */ 752 /** 753 * User Stored Events 754 * 755 * @typedef { function } EventListener 756 * @param { Object } evt - User events 757 * @syscap SystemCapability.Utils.Lang 758 * @crossplatform 759 * @atomicservice 760 * @since 12 761 */ 762 type EventListener = (evt: Object) => void; 763 764 /** 765 * Provides the ConditionType type,including timeout, killSignal, maxBuffer. 766 * 767 * @typedef ConditionType 768 * @syscap SystemCapability.Utils.Lang 769 * @systemapi Hide this for inner system use 770 * @since 10 771 * @test 772 */ 773 interface ConditionType { 774 775 /** 776 * Maximum running time (in ms) of the child process. 777 * 778 * @type { ?number } 779 * @syscap SystemCapability.Utils.Lang 780 * @systemapi Hide this for inner system use 781 * @since 10 782 * @test 783 */ 784 timeout?: number; 785 786 /** 787 * Signal sent to the child process when the running time of a child process exceeds the timeout period. 788 * 789 * @type { ?(number | string) } 790 * @syscap SystemCapability.Utils.Lang 791 * @systemapi Hide this for inner system use 792 * @since 10 793 * @test 794 */ 795 killSignal?: number | string; 796 797 /** 798 * Maximum buffer size for the standard input and output of the child process. 799 * 800 * @type { ?number } 801 * @syscap SystemCapability.Utils.Lang 802 * @systemapi Hide this for inner system use 803 * @since 10 804 * @test 805 */ 806 maxBuffer?: number; 807 } 808 /** 809 * Returns a child process object and spawns a new ChildProcess to run the command. 810 * 811 * @param { string } command - String of the shell commands executed by the child process. 812 * @param { ConditionType } options - This is an object. The object contains three parameters. Timeout is the running time of the child 813 * process, killSignal is the signal sent when the child process reaches timeout, and maxBuffer is the size of the 814 * maximum buffer area for standard input and output. 815 * @returns { ChildProcess } Returns a child process object. 816 * @syscap SystemCapability.Utils.Lang 817 * @systemapi Hide this for inner system use 818 * @since 7 819 * @test 820 */ 821 function runCmd( 822 command: string, 823 options?: ConditionType 824 ): ChildProcess; 825 826 /** 827 * Abort current process 828 * 829 * @syscap SystemCapability.Utils.Lang 830 * @since 7 831 */ 832 /** 833 * Abort current process 834 * 835 * @syscap SystemCapability.Utils.Lang 836 * @crossplatform 837 * @since 10 838 */ 839 /** 840 * Aborts a process and generates a core file. This method will cause a process to exit immediately. Exercise caution 841 * when using this method. 842 * 843 * @syscap SystemCapability.Utils.Lang 844 * @crossplatform 845 * @atomicservice 846 * @since 11 847 */ 848 function abort(): void; 849 850 /** 851 * Register for an event 852 * 853 * @param { string } type - Indicates the type of event registered. 854 * @param { EventListener } listener - Represents the registered event function 855 * @syscap SystemCapability.Utils.Lang 856 * @systemapi Hide this for inner system use 857 * @since 7 858 * @test 859 */ 860 function on(type: string, listener: EventListener): void; 861 862 /** 863 * Remove registered event 864 * 865 * @param { string } type - Remove the type of registered event. 866 * @returns { boolean } Return removed result. 867 * @syscap SystemCapability.Utils.Lang 868 * @systemapi Hide this for inner system use 869 * @since 7 870 * @test 871 */ 872 function off(type: string): boolean; 873 874 /** 875 * Process exit 876 * 877 * @param { number } code - Process exit code. 878 * @syscap SystemCapability.Utils.Lang 879 * @since 7 880 * @deprecated since 9 881 * @useinstead ohos.process.ProcessManager.exit 882 */ 883 function exit(code: number): void; 884 885 /** 886 * Return the current work directory; 887 * 888 * @returns { string } Return the current work directory. 889 * @syscap SystemCapability.Utils.Lang 890 * @systemapi Hide this for inner system use 891 * @since 7 892 * @test 893 */ 894 function cwd(): string; 895 896 /** 897 * Change current directory 898 * 899 * @param { string } dir - The path you want to change. 900 * @syscap SystemCapability.Utils.Lang 901 * @systemapi Hide this for inner system use 902 * @since 7 903 * @test 904 */ 905 function chdir(dir: string): void; 906 907 /** 908 * Returns the running time of the system 909 * 910 * @returns { number } Return the running time of the system. 911 * @syscap SystemCapability.Utils.Lang 912 * @since 7 913 */ 914 /** 915 * Returns the running time of the system 916 * 917 * @returns { number } Return the running time of the system. 918 * @syscap SystemCapability.Utils.Lang 919 * @crossplatform 920 * @since 10 921 */ 922 /** 923 * Obtains the running time of this process. 924 * 925 * @returns { number } Return the running time of the system. 926 * @syscap SystemCapability.Utils.Lang 927 * @crossplatform 928 * @atomicservice 929 * @since 11 930 */ 931 function uptime(): number; 932 933 /** 934 * Return whether the signal was sent successfully 935 * 936 * @param { number } signal - Signal sent. 937 * @param { number } pid - Send signal to target pid. 938 * @returns { boolean } Return the result of the signal. 939 * @syscap SystemCapability.Utils.Lang 940 * @since 7 941 * @deprecated since 9 942 * @useinstead ohos.process.ProcessManager.kill 943 */ 944 function kill(signal: number, pid: number): boolean; 945} 946export default process; 947