forked from bjmashibing/java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProcess.html
More file actions
963 lines (944 loc) · 44.4 KB
/
Process.html
File metadata and controls
963 lines (944 loc) · 44.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
<!DOCTYPE HTML>
<!-- NewPage -->
<html lang="en">
<head>
<!-- Generated by javadoc -->
<title>Process (Java SE 12 & JDK 12 )</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="keywords" content="java.lang.Process class">
<meta name="keywords" content="getOutputStream()">
<meta name="keywords" content="getInputStream()">
<meta name="keywords" content="getErrorStream()">
<meta name="keywords" content="waitFor()">
<meta name="keywords" content="exitValue()">
<meta name="keywords" content="destroy()">
<meta name="keywords" content="destroyForcibly()">
<meta name="keywords" content="supportsNormalTermination()">
<meta name="keywords" content="isAlive()">
<meta name="keywords" content="pid()">
<meta name="keywords" content="onExit()">
<meta name="keywords" content="toHandle()">
<meta name="keywords" content="info()">
<meta name="keywords" content="children()">
<meta name="keywords" content="descendants()">
<link rel="stylesheet" type="text/css" href="../../../stylesheet.css" title="Style">
<link rel="stylesheet" type="text/css" href="../../../jquery/jquery-ui.css" title="Style">
<script type="text/javascript" src="../../../script.js"></script>
<script type="text/javascript" src="../../../jquery/jszip/dist/jszip.min.js"></script>
<script type="text/javascript" src="../../../jquery/jszip-utils/dist/jszip-utils.min.js"></script>
<!--[if IE]>
<script type="text/javascript" src="../../../jquery/jszip-utils/dist/jszip-utils-ie.min.js"></script>
<![endif]-->
<script type="text/javascript" src="../../../jquery/jquery-3.3.1.js"></script>
<script type="text/javascript" src="../../../jquery/jquery-migrate-3.0.1.js"></script>
<script type="text/javascript" src="../../../jquery/jquery-ui.js"></script>
</head>
<body>
<script type="text/javascript"><!--
try {
if (location.href.indexOf('is-external=true') == -1) {
parent.document.title="Process (Java SE 12 & JDK 12 )";
}
}
catch(err) {
}
//-->
var data = {"i0":10,"i1":10,"i2":6,"i3":10,"i4":6,"i5":6,"i6":6,"i7":6,"i8":10,"i9":10,"i10":10,"i11":10,"i12":10,"i13":10,"i14":6,"i15":10};
var tabs = {65535:["t0","All Methods"],2:["t2","Instance Methods"],4:["t3","Abstract Methods"],8:["t4","Concrete Methods"]};
var altColor = "altColor";
var rowColor = "rowColor";
var tableTab = "tableTab";
var activeTableTab = "activeTableTab";
var pathtoroot = "../../../";
var useModuleDirectories = true;
loadScripts(document, 'script');</script>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
<header role="banner">
<nav role="navigation">
<div class="fixedNav">
<!-- ========= START OF TOP NAVBAR ======= -->
<div class="topNav"><a id="navbar.top">
<!-- -->
</a>
<div class="skipNav"><a href="#skip.navbar.top" title="Skip navigation links">Skip navigation links</a></div>
<a id="navbar.top.firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../index.html">Overview</a></li>
<li><a href="../../module-summary.html">Module</a></li>
<li><a href="package-summary.html">Package</a></li>
<li class="navBarCell1Rev">Class</li>
<li><a href="class-use/Process.html">Use</a></li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../index-files/index-1.html">Index</a></li>
<li><a href="../../../help-doc.html">Help</a></li>
</ul>
<div class="aboutLanguage"><div style="margin-top: 14px;"><strong>Java SE 12 & JDK 12</strong> </div></div>
</div>
<div class="subNav">
<div>
<ul class="subNavList">
<li>Summary: </li>
<li>Nested | </li>
<li>Field | </li>
<li><a href="#constructor.summary">Constr</a> | </li>
<li><a href="#method.summary">Method</a></li>
</ul>
<ul class="subNavList">
<li>Detail: </li>
<li>Field | </li>
<li><a href="#constructor.detail">Constr</a> | </li>
<li><a href="#method.detail">Method</a></li>
</ul>
</div>
<ul class="navListSearch">
<li><label for="search">SEARCH:</label>
<input type="text" id="search" value="search" disabled="disabled">
<input type="reset" id="reset" value="reset" disabled="disabled">
</li>
</ul>
</div>
<a id="skip.navbar.top">
<!-- -->
</a>
<!-- ========= END OF TOP NAVBAR ========= -->
</div>
<div class="navPadding"> </div>
<script type="text/javascript"><!--
$('.navPadding').css('padding-top', $('.fixedNav').css("height"));
//-->
</script>
</nav>
</header>
<!-- ======== START OF CLASS DATA ======== -->
<main role="main">
<div class="header">
<div class="subTitle"><span class="moduleLabelInType">Module</span> <a href="../../module-summary.html">java.base</a></div>
<div class="subTitle"><span class="packageLabelInType">Package</span> <a href="package-summary.html">java.lang</a></div>
<h2 title="Class Process" class="title">Class Process</h2>
</div>
<div class="contentContainer">
<ul class="inheritance">
<li><a href="Object.html" title="class in java.lang">java.lang.Object</a></li>
<li>
<ul class="inheritance">
<li>java.lang.Process</li>
</ul>
</li>
</ul>
<div class="description">
<ul class="blockList">
<li class="blockList">
<hr>
<pre>public abstract class <span class="typeNameLabel">Process</span>
extends <a href="Object.html" title="class in java.lang">Object</a></pre>
<div class="block"><code>Process</code> provides control of native processes started by
ProcessBuilder.start and Runtime.exec.
The class provides methods for performing input from the process, performing
output to the process, waiting for the process to complete,
checking the exit status of the process, and destroying (killing)
the process.
The <a href="ProcessBuilder.html#start()"><code>ProcessBuilder.start()</code></a> and
<a href="Runtime.html#exec(java.lang.String%5B%5D,java.lang.String%5B%5D,java.io.File)"><code>Runtime.exec</code></a>
methods create a native process and return an instance of a
subclass of <code>Process</code> that can be used to control the process
and obtain information about it.
<p>The methods that create processes may not work well for special
processes on certain native platforms, such as native windowing
processes, daemon processes, Win16/DOS processes on Microsoft
Windows, or shell scripts.
<p>By default, the created process does not have its own terminal
or console. All its standard I/O (i.e. stdin, stdout, stderr)
operations will be redirected to the parent process, where they can
be accessed via the streams obtained using the methods
<a href="#getOutputStream()"><code>getOutputStream()</code></a>,
<a href="#getInputStream()"><code>getInputStream()</code></a>, and
<a href="#getErrorStream()"><code>getErrorStream()</code></a>.
The parent process uses these streams to feed input to and get output
from the process. Because some native platforms only provide
limited buffer size for standard input and output streams, failure
to promptly write the input stream or read the output stream of
the process may cause the process to block, or even deadlock.
<p>Where desired, <a href="ProcessBuilder.html#redirect-input">
process I/O can also be redirected</a>
using methods of the <a href="ProcessBuilder.html" title="class in java.lang"><code>ProcessBuilder</code></a> class.
<p>The process is not killed when there are no more references to
the <code>Process</code> object, but rather the process
continues executing asynchronously.
<p>There is no requirement that the process represented by a <code>
Process</code> object execute asynchronously or concurrently with respect
to the Java process that owns the <code>Process</code> object.
<p>As of 1.5, <a href="ProcessBuilder.html#start()"><code>ProcessBuilder.start()</code></a> is the preferred way
to create a <code>Process</code>.
<p>Subclasses of Process should override the <a href="#onExit()"><code>onExit()</code></a> and
<a href="#toHandle()"><code>toHandle()</code></a> methods to provide a fully functional Process including the
<a href="#pid()">process id</a>,
<a href="#info()">information about the process</a>,
<a href="#children()">direct children</a>, and
<a href="#descendants()">direct children plus descendants of those children</a> of the process.
Delegating to the underlying Process or ProcessHandle is typically
easiest and most efficient.</div>
<dl>
<dt><span class="simpleTagLabel">Since:</span></dt>
<dd>1.0</dd>
</dl>
</li>
</ul>
</div>
<div class="summary">
<ul class="blockList">
<li class="blockList">
<!-- ======== CONSTRUCTOR SUMMARY ======== -->
<section role="region">
<ul class="blockList">
<li class="blockList"><a id="constructor.summary">
<!-- -->
</a>
<h3>Constructor Summary</h3>
<div class="memberSummary">
<table>
<caption><span>Constructors</span><span class="tabEnd"> </span></caption>
<tr>
<th class="colFirst" scope="col">Constructor</th>
<th class="colLast" scope="col">Description</th>
</tr>
<tbody>
<tr class="altColor">
<th class="colConstructorName" scope="row"><code><span class="memberNameLink"><a href="#%3Cinit%3E()">Process</a></span>()</code></th>
<td class="colLast">
<div class="block">Default constructor for Process.</div>
</td>
</tr>
</tbody>
</table>
</div>
</li>
</ul>
</section>
<!-- ========== METHOD SUMMARY =========== -->
<section role="region">
<ul class="blockList">
<li class="blockList"><a id="method.summary">
<!-- -->
</a>
<h3>Method Summary</h3>
<div class="memberSummary">
<div role="tablist" aria-orientation="horizontal"><button role="tab" aria-selected="true" aria-controls="memberSummary_tabpanel" tabindex="0" onkeydown="switchTab(event)" id="t0" class="activeTableTab">All Methods</button><button role="tab" aria-selected="false" aria-controls="memberSummary_tabpanel" tabindex="-1" onkeydown="switchTab(event)" id="t2" class="tableTab" onclick="show(2);">Instance Methods</button><button role="tab" aria-selected="false" aria-controls="memberSummary_tabpanel" tabindex="-1" onkeydown="switchTab(event)" id="t3" class="tableTab" onclick="show(4);">Abstract Methods</button><button role="tab" aria-selected="false" aria-controls="memberSummary_tabpanel" tabindex="-1" onkeydown="switchTab(event)" id="t4" class="tableTab" onclick="show(8);">Concrete Methods</button></div>
<div id="memberSummary_tabpanel" role="tabpanel">
<table aria-labelledby="t0">
<tr>
<th class="colFirst" scope="col">Modifier and Type</th>
<th class="colSecond" scope="col">Method</th>
<th class="colLast" scope="col">Description</th>
</tr>
<tbody>
<tr class="altColor" id="i0">
<td class="colFirst"><code><a href="../util/stream/Stream.html" title="interface in java.util.stream">Stream</a><<a href="ProcessHandle.html" title="interface in java.lang">ProcessHandle</a>></code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#children()">children</a></span>()</code></th>
<td class="colLast">
<div class="block">Returns a snapshot of the direct children of the process.</div>
</td>
</tr>
<tr class="rowColor" id="i1">
<td class="colFirst"><code><a href="../util/stream/Stream.html" title="interface in java.util.stream">Stream</a><<a href="ProcessHandle.html" title="interface in java.lang">ProcessHandle</a>></code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#descendants()">descendants</a></span>()</code></th>
<td class="colLast">
<div class="block">Returns a snapshot of the descendants of the process.</div>
</td>
</tr>
<tr class="altColor" id="i2">
<td class="colFirst"><code>abstract void</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#destroy()">destroy</a></span>()</code></th>
<td class="colLast">
<div class="block">Kills the process.</div>
</td>
</tr>
<tr class="rowColor" id="i3">
<td class="colFirst"><code><a href="Process.html" title="class in java.lang">Process</a></code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#destroyForcibly()">destroyForcibly</a></span>()</code></th>
<td class="colLast">
<div class="block">Kills the process forcibly.</div>
</td>
</tr>
<tr class="altColor" id="i4">
<td class="colFirst"><code>abstract int</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#exitValue()">exitValue</a></span>()</code></th>
<td class="colLast">
<div class="block">Returns the exit value for the process.</div>
</td>
</tr>
<tr class="rowColor" id="i5">
<td class="colFirst"><code>abstract <a href="../io/InputStream.html" title="class in java.io">InputStream</a></code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#getErrorStream()">getErrorStream</a></span>()</code></th>
<td class="colLast">
<div class="block">Returns the input stream connected to the error output of the
process.</div>
</td>
</tr>
<tr class="altColor" id="i6">
<td class="colFirst"><code>abstract <a href="../io/InputStream.html" title="class in java.io">InputStream</a></code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#getInputStream()">getInputStream</a></span>()</code></th>
<td class="colLast">
<div class="block">Returns the input stream connected to the normal output of the
process.</div>
</td>
</tr>
<tr class="rowColor" id="i7">
<td class="colFirst"><code>abstract <a href="../io/OutputStream.html" title="class in java.io">OutputStream</a></code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#getOutputStream()">getOutputStream</a></span>()</code></th>
<td class="colLast">
<div class="block">Returns the output stream connected to the normal input of the
process.</div>
</td>
</tr>
<tr class="altColor" id="i8">
<td class="colFirst"><code><a href="ProcessHandle.Info.html" title="interface in java.lang">ProcessHandle.Info</a></code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#info()">info</a></span>()</code></th>
<td class="colLast">
<div class="block">Returns a snapshot of information about the process.</div>
</td>
</tr>
<tr class="rowColor" id="i9">
<td class="colFirst"><code>boolean</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#isAlive()">isAlive</a></span>()</code></th>
<td class="colLast">
<div class="block">Tests whether the process represented by this <code>Process</code> is
alive.</div>
</td>
</tr>
<tr class="altColor" id="i10">
<td class="colFirst"><code><a href="../util/concurrent/CompletableFuture.html" title="class in java.util.concurrent">CompletableFuture</a><<a href="Process.html" title="class in java.lang">Process</a>></code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#onExit()">onExit</a></span>()</code></th>
<td class="colLast">
<div class="block">Returns a <code>CompletableFuture<Process></code> for the termination of the Process.</div>
</td>
</tr>
<tr class="rowColor" id="i11">
<td class="colFirst"><code>long</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#pid()">pid</a></span>()</code></th>
<td class="colLast">
<div class="block">Returns the native process ID of the process.</div>
</td>
</tr>
<tr class="altColor" id="i12">
<td class="colFirst"><code>boolean</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#supportsNormalTermination()">supportsNormalTermination</a></span>()</code></th>
<td class="colLast">
<div class="block">Returns <code>true</code> if the implementation of <a href="#destroy()"><code>destroy()</code></a> is to
normally terminate the process,
Returns <code>false</code> if the implementation of <code>destroy</code>
forcibly and immediately terminates the process.</div>
</td>
</tr>
<tr class="rowColor" id="i13">
<td class="colFirst"><code><a href="ProcessHandle.html" title="interface in java.lang">ProcessHandle</a></code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#toHandle()">toHandle</a></span>()</code></th>
<td class="colLast">
<div class="block">Returns a ProcessHandle for the Process.</div>
</td>
</tr>
<tr class="altColor" id="i14">
<td class="colFirst"><code>abstract int</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#waitFor()">waitFor</a></span>()</code></th>
<td class="colLast">
<div class="block">Causes the current thread to wait, if necessary, until the
process represented by this <code>Process</code> object has
terminated.</div>
</td>
</tr>
<tr class="rowColor" id="i15">
<td class="colFirst"><code>boolean</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#waitFor(long,java.util.concurrent.TimeUnit)">waitFor</a></span>​(long timeout,
<a href="../util/concurrent/TimeUnit.html" title="enum in java.util.concurrent">TimeUnit</a> unit)</code></th>
<td class="colLast">
<div class="block">Causes the current thread to wait, if necessary, until the
process represented by this <code>Process</code> object has
terminated, or the specified waiting time elapses.</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<ul class="blockList">
<li class="blockList"><a id="methods.inherited.from.class.java.lang.Object">
<!-- -->
</a>
<h3>Methods declared in class java.lang.<a href="Object.html" title="class in java.lang">Object</a></h3>
<code><a href="Object.html#clone()">clone</a>, <a href="Object.html#equals(java.lang.Object)">equals</a>, <a href="Object.html#finalize()">finalize</a>, <a href="Object.html#getClass()">getClass</a>, <a href="Object.html#hashCode()">hashCode</a>, <a href="Object.html#notify()">notify</a>, <a href="Object.html#notifyAll()">notifyAll</a>, <a href="Object.html#toString()">toString</a>, <a href="Object.html#wait()">wait</a>, <a href="Object.html#wait(long)">wait</a>, <a href="Object.html#wait(long,int)">wait</a></code></li>
</ul>
</li>
</ul>
</section>
</li>
</ul>
</div>
<div class="details">
<ul class="blockList">
<li class="blockList">
<!-- ========= CONSTRUCTOR DETAIL ======== -->
<section role="region">
<ul class="blockList">
<li class="blockList"><a id="constructor.detail">
<!-- -->
</a>
<h3>Constructor Detail</h3>
<a id="<init>()">
<!-- -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>Process</h4>
<pre>public Process()</pre>
<div class="block">Default constructor for Process.</div>
</li>
</ul>
</li>
</ul>
</section>
<!-- ============ METHOD DETAIL ========== -->
<section role="region">
<ul class="blockList">
<li class="blockList"><a id="method.detail">
<!-- -->
</a>
<h3>Method Detail</h3>
<a id="getOutputStream()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getOutputStream</h4>
<pre class="methodSignature">public abstract <a href="../io/OutputStream.html" title="class in java.io">OutputStream</a> getOutputStream()</pre>
<div class="block">Returns the output stream connected to the normal input of the
process. Output to the stream is piped into the standard
input of the process represented by this <code>Process</code> object.
<p>If the standard input of the process has been redirected using
<a href="ProcessBuilder.html#redirectInput(java.lang.ProcessBuilder.Redirect)"><code>ProcessBuilder.redirectInput</code></a>
then this method will return a
<a href="ProcessBuilder.html#redirect-input">null output stream</a>.
<p>Implementation note: It is a good idea for the returned
output stream to be buffered.</div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the output stream connected to the normal input of the
process</dd>
</dl>
</li>
</ul>
<a id="getInputStream()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getInputStream</h4>
<pre class="methodSignature">public abstract <a href="../io/InputStream.html" title="class in java.io">InputStream</a> getInputStream()</pre>
<div class="block">Returns the input stream connected to the normal output of the
process. The stream obtains data piped from the standard
output of the process represented by this <code>Process</code> object.
<p>If the standard output of the process has been redirected using
<a href="ProcessBuilder.html#redirectOutput(java.lang.ProcessBuilder.Redirect)"><code>ProcessBuilder.redirectOutput</code></a>
then this method will return a
<a href="ProcessBuilder.html#redirect-output">null input stream</a>.
<p>Otherwise, if the standard error of the process has been
redirected using
<a href="ProcessBuilder.html#redirectErrorStream(boolean)"><code>ProcessBuilder.redirectErrorStream</code></a>
then the input stream returned by this method will receive the
merged standard output and the standard error of the process.
<p>Implementation note: It is a good idea for the returned
input stream to be buffered.</div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the input stream connected to the normal output of the
process</dd>
</dl>
</li>
</ul>
<a id="getErrorStream()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getErrorStream</h4>
<pre class="methodSignature">public abstract <a href="../io/InputStream.html" title="class in java.io">InputStream</a> getErrorStream()</pre>
<div class="block">Returns the input stream connected to the error output of the
process. The stream obtains data piped from the error output
of the process represented by this <code>Process</code> object.
<p>If the standard error of the process has been redirected using
<a href="ProcessBuilder.html#redirectError(java.lang.ProcessBuilder.Redirect)"><code>ProcessBuilder.redirectError</code></a> or
<a href="ProcessBuilder.html#redirectErrorStream(boolean)"><code>ProcessBuilder.redirectErrorStream</code></a>
then this method will return a
<a href="ProcessBuilder.html#redirect-output">null input stream</a>.
<p>Implementation note: It is a good idea for the returned
input stream to be buffered.</div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the input stream connected to the error output of
the process</dd>
</dl>
</li>
</ul>
<a id="waitFor()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>waitFor</h4>
<pre class="methodSignature">public abstract int waitFor()
throws <a href="InterruptedException.html" title="class in java.lang">InterruptedException</a></pre>
<div class="block">Causes the current thread to wait, if necessary, until the
process represented by this <code>Process</code> object has
terminated. This method returns immediately if the process
has already terminated. If the process has not yet
terminated, the calling thread will be blocked until the
process exits.</div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the exit value of the process represented by this
<code>Process</code> object. By convention, the value
<code>0</code> indicates normal termination.</dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code><a href="InterruptedException.html" title="class in java.lang">InterruptedException</a></code> - if the current thread is
<a href="Thread.html#interrupt()">interrupted</a> by another
thread while it is waiting, then the wait is ended and
an <a href="InterruptedException.html" title="class in java.lang"><code>InterruptedException</code></a> is thrown.</dd>
</dl>
</li>
</ul>
<a id="waitFor(long,java.util.concurrent.TimeUnit)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>waitFor</h4>
<pre class="methodSignature">public boolean waitFor​(long timeout,
<a href="../util/concurrent/TimeUnit.html" title="enum in java.util.concurrent">TimeUnit</a> unit)
throws <a href="InterruptedException.html" title="class in java.lang">InterruptedException</a></pre>
<div class="block">Causes the current thread to wait, if necessary, until the
process represented by this <code>Process</code> object has
terminated, or the specified waiting time elapses.
<p>If the process has already terminated then this method returns
immediately with the value <code>true</code>. If the process has not
terminated and the timeout value is less than, or equal to, zero, then
this method returns immediately with the value <code>false</code>.
<p>The default implementation of this methods polls the <code>exitValue</code>
to check if the process has terminated. Concrete implementations of this
class are strongly encouraged to override this method with a more
efficient implementation.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>timeout</code> - the maximum time to wait</dd>
<dd><code>unit</code> - the time unit of the <code>timeout</code> argument</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd><code>true</code> if the process has exited and <code>false</code> if
the waiting time elapsed before the process has exited.</dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code><a href="InterruptedException.html" title="class in java.lang">InterruptedException</a></code> - if the current thread is interrupted
while waiting.</dd>
<dd><code><a href="NullPointerException.html" title="class in java.lang">NullPointerException</a></code> - if unit is null</dd>
<dt><span class="simpleTagLabel">Since:</span></dt>
<dd>1.8</dd>
</dl>
</li>
</ul>
<a id="exitValue()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>exitValue</h4>
<pre class="methodSignature">public abstract int exitValue()</pre>
<div class="block">Returns the exit value for the process.</div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the exit value of the process represented by this
<code>Process</code> object. By convention, the value
<code>0</code> indicates normal termination.</dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code><a href="IllegalThreadStateException.html" title="class in java.lang">IllegalThreadStateException</a></code> - if the process represented
by this <code>Process</code> object has not yet terminated</dd>
</dl>
</li>
</ul>
<a id="destroy()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>destroy</h4>
<pre class="methodSignature">public abstract void destroy()</pre>
<div class="block">Kills the process.
Whether the process represented by this <code>Process</code> object is
<a href="#supportsNormalTermination()">normally terminated</a> or not is
implementation dependent.
Forcible process destruction is defined as the immediate termination of a
process, whereas normal termination allows the process to shut down cleanly.
If the process is not alive, no action is taken.
<p>
The <a href="../util/concurrent/CompletableFuture.html" title="class in java.util.concurrent"><code>CompletableFuture</code></a> from <a href="#onExit()"><code>onExit()</code></a> is
<a href="../util/concurrent/CompletableFuture.html#complete(T)">completed</a>
when the process has terminated.</div>
</li>
</ul>
<a id="destroyForcibly()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>destroyForcibly</h4>
<pre class="methodSignature">public <a href="Process.html" title="class in java.lang">Process</a> destroyForcibly()</pre>
<div class="block">Kills the process forcibly. The process represented by this
<code>Process</code> object is forcibly terminated.
Forcible process destruction is defined as the immediate termination of a
process, whereas normal termination allows the process to shut down cleanly.
If the process is not alive, no action is taken.
<p>
The <a href="../util/concurrent/CompletableFuture.html" title="class in java.util.concurrent"><code>CompletableFuture</code></a> from <a href="#onExit()"><code>onExit()</code></a> is
<a href="../util/concurrent/CompletableFuture.html#complete(T)">completed</a>
when the process has terminated.
<p>
Invoking this method on <code>Process</code> objects returned by
<a href="ProcessBuilder.html#start()"><code>ProcessBuilder.start()</code></a> and <a href="Runtime.html#exec(java.lang.String)"><code>Runtime.exec(java.lang.String)</code></a> forcibly terminate
the process.</div>
<dl>
<dt><span class="simpleTagLabel">API Note:</span></dt>
<dd>The process may not terminate immediately.
i.e. <code>isAlive()</code> may return true for a brief period
after <code>destroyForcibly()</code> is called. This method
may be chained to <code>waitFor()</code> if needed.</dd>
<dt><span class="simpleTagLabel">Implementation Requirements:</span></dt>
<dd>The default implementation of this method invokes <a href="#destroy()"><code>destroy()</code></a>
and so may not forcibly terminate the process.</dd>
<dt><span class="simpleTagLabel">Implementation Note:</span></dt>
<dd>Concrete implementations of this class are strongly encouraged to override
this method with a compliant implementation.</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the <code>Process</code> object representing the
process forcibly destroyed</dd>
<dt><span class="simpleTagLabel">Since:</span></dt>
<dd>1.8</dd>
</dl>
</li>
</ul>
<a id="supportsNormalTermination()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>supportsNormalTermination</h4>
<pre class="methodSignature">public boolean supportsNormalTermination()</pre>
<div class="block">Returns <code>true</code> if the implementation of <a href="#destroy()"><code>destroy()</code></a> is to
normally terminate the process,
Returns <code>false</code> if the implementation of <code>destroy</code>
forcibly and immediately terminates the process.
<p>
Invoking this method on <code>Process</code> objects returned by
<a href="ProcessBuilder.html#start()"><code>ProcessBuilder.start()</code></a> and <a href="Runtime.html#exec(java.lang.String)"><code>Runtime.exec(java.lang.String)</code></a> return
<code>true</code> or <code>false</code> depending on the platform implementation.</div>
<dl>
<dt><span class="simpleTagLabel">Implementation Requirements:</span></dt>
<dd>This implementation throws an instance of
<a href="UnsupportedOperationException.html" title="class in java.lang"><code>UnsupportedOperationException</code></a> and performs no other action.</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd><code>true</code> if the implementation of <a href="#destroy()"><code>destroy()</code></a> is to
normally terminate the process;
otherwise, <a href="#destroy()"><code>destroy()</code></a> forcibly terminates the process</dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code><a href="UnsupportedOperationException.html" title="class in java.lang">UnsupportedOperationException</a></code> - if the Process implementation
does not support this operation</dd>
<dt><span class="simpleTagLabel">Since:</span></dt>
<dd>9</dd>
</dl>
</li>
</ul>
<a id="isAlive()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>isAlive</h4>
<pre class="methodSignature">public boolean isAlive()</pre>
<div class="block">Tests whether the process represented by this <code>Process</code> is
alive.</div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd><code>true</code> if the process represented by this
<code>Process</code> object has not yet terminated.</dd>
<dt><span class="simpleTagLabel">Since:</span></dt>
<dd>1.8</dd>
</dl>
</li>
</ul>
<a id="pid()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>pid</h4>
<pre class="methodSignature">public long pid()</pre>
<div class="block">Returns the native process ID of the process.
The native process ID is an identification number that the operating
system assigns to the process.</div>
<dl>
<dt><span class="simpleTagLabel">Implementation Requirements:</span></dt>
<dd>The implementation of this method returns the process id as:
<a href="#toHandle()"><code>toHandle().pid()</code></a>.</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the native process id of the process</dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code><a href="UnsupportedOperationException.html" title="class in java.lang">UnsupportedOperationException</a></code> - if the Process implementation
does not support this operation</dd>
<dt><span class="simpleTagLabel">Since:</span></dt>
<dd>9</dd>
</dl>
</li>
</ul>
<a id="onExit()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>onExit</h4>
<pre class="methodSignature">public <a href="../util/concurrent/CompletableFuture.html" title="class in java.util.concurrent">CompletableFuture</a><<a href="Process.html" title="class in java.lang">Process</a>> onExit()</pre>
<div class="block">Returns a <code>CompletableFuture<Process></code> for the termination of the Process.
The <a href="../util/concurrent/CompletableFuture.html" title="class in java.util.concurrent"><code>CompletableFuture</code></a> provides the ability
to trigger dependent functions or actions that may be run synchronously
or asynchronously upon process termination.
When the process has terminated the CompletableFuture is
<a href="../util/concurrent/CompletableFuture.html#complete(T)"><code>completed</code></a> regardless
of the exit status of the process.
<p>
Calling <code>onExit().get()</code> waits for the process to terminate and returns
the Process. The future can be used to check if the process is
<a href="../util/concurrent/CompletableFuture.html#isDone()">done</a> or to
<a href="../util/concurrent/CompletableFuture.html#get()">wait</a> for it to terminate.
<a href="../util/concurrent/CompletableFuture.html#cancel(boolean)">Cancelling</a>
the CompletableFuture does not affect the Process.
<p>
Processes returned from <a href="ProcessBuilder.html#start()"><code>ProcessBuilder.start()</code></a> override the
default implementation to provide an efficient mechanism to wait
for process exit.</div>
<dl>
<dt><span class="simpleTagLabel">API Note:</span></dt>
<dd>Using <a href="#onExit()"><code>onExit</code></a> is an alternative to
<a href="#waitFor()"><code>waitFor</code></a> that enables both additional concurrency
and convenient access to the result of the Process.
Lambda expressions can be used to evaluate the result of the Process
execution.
If there is other processing to be done before the value is used
then <a href="#onExit()">onExit</a> is a convenient mechanism to
free the current thread and block only if and when the value is needed.
<br>
For example, launching a process to compare two files and get a boolean if they are identical:
<pre> <code> Process p = new ProcessBuilder("cmp", "f1", "f2").start();
Future<Boolean> identical = p.onExit().thenApply(p1 -> p1.exitValue() == 0);
...
if (identical.get()) { ... }
</code></pre>, The process may be observed to have terminated with <a href="#isAlive()"><code>isAlive()</code></a>
before the ComputableFuture is completed and dependent actions are invoked.</dd>
<dt><span class="simpleTagLabel">Implementation Requirements:</span></dt>
<dd>This implementation executes <a href="#waitFor()"><code>waitFor()</code></a> in a separate thread
repeatedly until it returns successfully. If the execution of
<code>waitFor</code> is interrupted, the thread's interrupt status is preserved.
<p>
When <a href="#waitFor()"><code>waitFor()</code></a> returns successfully the CompletableFuture is
<a href="../util/concurrent/CompletableFuture.html#complete(T)">completed</a> regardless
of the exit status of the process.
This implementation may consume a lot of memory for thread stacks if a
large number of processes are waited for concurrently.
<p>
External implementations should override this method and provide
a more efficient implementation. For example, to delegate to the underlying
process, it can do the following:
<pre><code>
public CompletableFuture<Process> onExit() {
return delegate.onExit().thenApply(p -> this);
}
</code></pre></dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>a new <code>CompletableFuture<Process></code> for the Process</dd>
<dt><span class="simpleTagLabel">Since:</span></dt>
<dd>9</dd>
</dl>
</li>
</ul>
<a id="toHandle()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>toHandle</h4>
<pre class="methodSignature">public <a href="ProcessHandle.html" title="interface in java.lang">ProcessHandle</a> toHandle()</pre>
<div class="block">Returns a ProcessHandle for the Process.
<code>Process</code> objects returned by <a href="ProcessBuilder.html#start()"><code>ProcessBuilder.start()</code></a> and
<a href="Runtime.html#exec(java.lang.String)"><code>Runtime.exec(java.lang.String)</code></a> implement <code>toHandle</code> as the equivalent of
<a href="ProcessHandle.html#of(long)"><code>ProcessHandle.of(pid)</code></a> including the
check for a SecurityManager and <code>RuntimePermission("manageProcess")</code>.</div>
<dl>
<dt><span class="simpleTagLabel">Implementation Requirements:</span></dt>
<dd>This implementation throws an instance of
<a href="UnsupportedOperationException.html" title="class in java.lang"><code>UnsupportedOperationException</code></a> and performs no other action.
Subclasses should override this method to provide a ProcessHandle for the
process. The methods <a href="#pid()"><code>pid()</code></a>, <a href="#info()"><code>info()</code></a>, <a href="#children()"><code>children()</code></a>,
and <a href="#descendants()"><code>descendants()</code></a>, unless overridden, operate on the ProcessHandle.</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>Returns a ProcessHandle for the Process</dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code><a href="UnsupportedOperationException.html" title="class in java.lang">UnsupportedOperationException</a></code> - if the Process implementation
does not support this operation</dd>
<dd><code><a href="SecurityException.html" title="class in java.lang">SecurityException</a></code> - if a security manager has been installed and
it denies RuntimePermission("manageProcess")</dd>
<dt><span class="simpleTagLabel">Since:</span></dt>
<dd>9</dd>
</dl>
</li>
</ul>
<a id="info()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>info</h4>
<pre class="methodSignature">public <a href="ProcessHandle.Info.html" title="interface in java.lang">ProcessHandle.Info</a> info()</pre>
<div class="block">Returns a snapshot of information about the process.
<p> A <a href="ProcessHandle.Info.html" title="interface in java.lang"><code>ProcessHandle.Info</code></a> instance has accessor methods
that return information about the process if it is available.</div>
<dl>
<dt><span class="simpleTagLabel">Implementation Requirements:</span></dt>
<dd>This implementation returns information about the process as:
<a href="#toHandle()"><code>toHandle().info()</code></a>.</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>a snapshot of information about the process, always non-null</dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code><a href="UnsupportedOperationException.html" title="class in java.lang">UnsupportedOperationException</a></code> - if the Process implementation
does not support this operation</dd>
<dt><span class="simpleTagLabel">Since:</span></dt>
<dd>9</dd>
</dl>
</li>
</ul>
<a id="children()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>children</h4>
<pre class="methodSignature">public <a href="../util/stream/Stream.html" title="interface in java.util.stream">Stream</a><<a href="ProcessHandle.html" title="interface in java.lang">ProcessHandle</a>> children()</pre>
<div class="block">Returns a snapshot of the direct children of the process.
The parent of a direct child process is the process.
Typically, a process that is <a href="#isAlive()">not alive</a> has no children.
<p>
<em>Note that processes are created and terminate asynchronously.
There is no guarantee that a process is <a href="#isAlive()">alive</a>.
</em></div>
<dl>
<dt><span class="simpleTagLabel">Implementation Requirements:</span></dt>
<dd>This implementation returns the direct children as:
<a href="#toHandle()"><code>toHandle().children()</code></a>.</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>a sequential Stream of ProcessHandles for processes that are
direct children of the process</dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code><a href="UnsupportedOperationException.html" title="class in java.lang">UnsupportedOperationException</a></code> - if the Process implementation
does not support this operation</dd>
<dd><code><a href="SecurityException.html" title="class in java.lang">SecurityException</a></code> - if a security manager has been installed and
it denies RuntimePermission("manageProcess")</dd>
<dt><span class="simpleTagLabel">Since:</span></dt>
<dd>9</dd>
</dl>
</li>
</ul>
<a id="descendants()">
<!-- -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>descendants</h4>
<pre class="methodSignature">public <a href="../util/stream/Stream.html" title="interface in java.util.stream">Stream</a><<a href="ProcessHandle.html" title="interface in java.lang">ProcessHandle</a>> descendants()</pre>
<div class="block">Returns a snapshot of the descendants of the process.
The descendants of a process are the children of the process
plus the descendants of those children, recursively.
Typically, a process that is <a href="#isAlive()">not alive</a> has no children.
<p>
<em>Note that processes are created and terminate asynchronously.
There is no guarantee that a process is <a href="#isAlive()">alive</a>.
</em></div>
<dl>
<dt><span class="simpleTagLabel">Implementation Requirements:</span></dt>
<dd>This implementation returns all children as:
<a href="#toHandle()"><code>toHandle().descendants()</code></a>.</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>a sequential Stream of ProcessHandles for processes that
are descendants of the process</dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code><a href="UnsupportedOperationException.html" title="class in java.lang">UnsupportedOperationException</a></code> - if the Process implementation
does not support this operation</dd>
<dd><code><a href="SecurityException.html" title="class in java.lang">SecurityException</a></code> - if a security manager has been installed and
it denies RuntimePermission("manageProcess")</dd>
<dt><span class="simpleTagLabel">Since:</span></dt>
<dd>9</dd>
</dl>
</li>
</ul>
</li>
</ul>
</section>
</li>
</ul>
</div>
</div>
</main>
<!-- ========= END OF CLASS DATA ========= -->
<footer role="contentinfo">
<nav role="navigation">
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<div class="bottomNav"><a id="navbar.bottom">
<!-- -->
</a>
<div class="skipNav"><a href="#skip.navbar.bottom" title="Skip navigation links">Skip navigation links</a></div>
<a id="navbar.bottom.firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../index.html">Overview</a></li>
<li><a href="../../module-summary.html">Module</a></li>
<li><a href="package-summary.html">Package</a></li>
<li class="navBarCell1Rev">Class</li>
<li><a href="class-use/Process.html">Use</a></li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../index-files/index-1.html">Index</a></li>
<li><a href="../../../help-doc.html">Help</a></li>
</ul>
<div class="aboutLanguage"><div style="margin-top: 14px;"><strong>Java SE 12 & JDK 12</strong> </div></div>
</div>
<div class="subNav">
<div>
<ul class="subNavList">
<li>Summary: </li>
<li>Nested | </li>
<li>Field | </li>
<li><a href="#constructor.summary">Constr</a> | </li>
<li><a href="#method.summary">Method</a></li>
</ul>
<ul class="subNavList">
<li>Detail: </li>
<li>Field | </li>
<li><a href="#constructor.detail">Constr</a> | </li>
<li><a href="#method.detail">Method</a></li>
</ul>
</div>
</div>
<a id="skip.navbar.bottom">
<!-- -->
</a>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
</nav>
<p class="legalCopy"><small><a href="https://bugreport.java.com/bugreport/">Report a bug or suggest an enhancement</a><br> For further API reference and developer documentation see the <a href="https://docs.oracle.com/pls/topic/lookup?ctx=javase12.0.2&id=homepage" target="_blank">Java SE Documentation</a>, which contains more detailed, developer-targeted descriptions with conceptual overviews, definitions of terms, workarounds, and working code examples.<br> Java is a trademark or registered trademark of Oracle and/or its affiliates in the US and other countries.<br> <a href="../../../../legal/copyright.html">Copyright</a> © 1993, 2019, Oracle and/or its affiliates, 500 Oracle Parkway, Redwood Shores, CA 94065 USA.<br>All rights reserved. Use is subject to <a href="https://www.oracle.com/technetwork/java/javase/terms/license/java12.0.2speclicense.html">license terms</a> and the <a href="https://www.oracle.com/technetwork/java/redist-137594.html">documentation redistribution policy</a>. <!-- Version 12.0.2+10 --></small></p>
</footer>
</body>
</html>