<html><head></head><body><div style="color:#000; background-color:#fff; font-family:HelveticaNeue-Light, Helvetica Neue Light, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:16px"><div id="yui_3_16_0_ym19_1_1483687514550_2404"><span>Hi all,</span></div><div id="yui_3_16_0_ym19_1_1483687514550_2404"><span><br></span></div><div id="yui_3_16_0_ym19_1_1483687514550_2404" dir="ltr"><span id="yui_3_16_0_ym19_1_1483687514550_3274">I'm currently still learning Swift 3. Now I'm playing around with GCD (grand central dispatch). I'd like to start an external process using Process from an asynced thread, and create another thread to stop that external process after some times. Here's what I do</span>…</div><div id="yui_3_16_0_ym19_1_1483687514550_2404" dir="ltr"><span><br></span></div><div style="margin-top: 0px; margin-bottom: 0px; font-size: 12px; line-height: normal; font-family: Menlo;" id="yui_3_16_0_ym19_1_1483687514550_3921"><span style="font-variant-ligatures: no-common-ligatures; color: #35568a" id="yui_3_16_0_ym19_1_1483687514550_3922">import</span><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_ym19_1_1483687514550_3923"> Foundation</span></div><div style="margin-top: 0px; margin-bottom: 0px; font-size: 12px; line-height: normal; font-family: Menlo;" id="yui_3_16_0_ym19_1_1483687514550_3924"><span style="font-variant-ligatures: no-common-ligatures; color: #35568a" id="yui_3_16_0_ym19_1_1483687514550_3925">import</span><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_ym19_1_1483687514550_3926"> Dispatch</span></div><div style="margin-top: 0px; margin-bottom: 0px; font-size: 12px; line-height: normal; font-family: Menlo; min-height: 14px;" id="yui_3_16_0_ym19_1_1483687514550_3927"><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_ym19_1_1483687514550_3928"></span><br id="yui_3_16_0_ym19_1_1483687514550_3929"></div><div style="margin-top: 0px; margin-bottom: 0px; font-size: 12px; line-height: normal; font-family: Menlo; color: rgb(53, 86, 138);" id="yui_3_16_0_ym19_1_1483687514550_3930"><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_ym19_1_1483687514550_3931">extension</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" id="yui_3_16_0_ym19_1_1483687514550_3932"> </span><span style="font-variant-ligatures: no-common-ligatures; color: #c35900" id="yui_3_16_0_ym19_1_1483687514550_3933">Process</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" id="yui_3_16_0_ym19_1_1483687514550_3934"> {</span></div><div style="margin-top: 0px; margin-bottom: 0px; font-size: 12px; line-height: normal; font-family: Menlo;" id="yui_3_16_0_ym19_1_1483687514550_3935"><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_ym19_1_1483687514550_3936">&nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #35568a" id="yui_3_16_0_ym19_1_1483687514550_3937">func</span><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_ym19_1_1483687514550_3938"> execute(command: </span><span style="font-variant-ligatures: no-common-ligatures; color: #c35900" id="yui_3_16_0_ym19_1_1483687514550_3939">String</span><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_ym19_1_1483687514550_3940">, currentDir: </span><span style="font-variant-ligatures: no-common-ligatures; color: #c35900" id="yui_3_16_0_ym19_1_1483687514550_3941">String</span><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_ym19_1_1483687514550_3942"> = </span><span style="font-variant-ligatures: no-common-ligatures; color: #e82300" id="yui_3_16_0_ym19_1_1483687514550_3943">"~"</span><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_ym19_1_1483687514550_3944">, arguments: [</span><span style="font-variant-ligatures: no-common-ligatures; color: #c35900" id="yui_3_16_0_ym19_1_1483687514550_3945">String</span><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_ym19_1_1483687514550_3946">] = [], input: </span><span style="font-variant-ligatures: no-common-ligatures; color: #c35900" id="yui_3_16_0_ym19_1_1483687514550_3947">String</span><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_ym19_1_1483687514550_3948"> = </span><span style="font-variant-ligatures: no-common-ligatures; color: #e82300" id="yui_3_16_0_ym19_1_1483687514550_3949">""</span><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_ym19_1_1483687514550_3950">) -&gt; </span><span style="font-variant-ligatures: no-common-ligatures; color: #c35900" id="yui_3_16_0_ym19_1_1483687514550_3951">String</span><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_ym19_1_1483687514550_3952"> {</span></div><div style="margin-top: 0px; margin-bottom: 0px; font-size: 12px; line-height: normal; font-family: Menlo;" id="yui_3_16_0_ym19_1_1483687514550_3953"><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_ym19_1_1483687514550_3954">&nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #35568a" id="yui_3_16_0_ym19_1_1483687514550_3955">if</span><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_ym19_1_1483687514550_3956"> </span><span style="font-variant-ligatures: no-common-ligatures; color: #587ea8" id="yui_3_16_0_ym19_1_1483687514550_3957">!</span><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_ym19_1_1483687514550_3958">input.</span><span style="font-variant-ligatures: no-common-ligatures; color: #587ea8" id="yui_3_16_0_ym19_1_1483687514550_3959">isEmpty</span><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_ym19_1_1483687514550_3960"> {</span></div><div style="margin-top: 0px; margin-bottom: 0px; font-size: 12px; line-height: normal; font-family: Menlo;" id="yui_3_16_0_ym19_1_1483687514550_3961"><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_ym19_1_1483687514550_3962">&nbsp; &nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #35568a" id="yui_3_16_0_ym19_1_1483687514550_3963">let</span><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_ym19_1_1483687514550_3964"> pipeIn = </span><span style="font-variant-ligatures: no-common-ligatures; color: #c35900" id="yui_3_16_0_ym19_1_1483687514550_3965">Pipe</span><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_ym19_1_1483687514550_3966">()</span></div><div style="margin-top: 0px; margin-bottom: 0px; font-size: 12px; line-height: normal; font-family: Menlo;" id="yui_3_16_0_ym19_1_1483687514550_3967"><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_ym19_1_1483687514550_3968">&nbsp; &nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #35568a" id="yui_3_16_0_ym19_1_1483687514550_3969">self</span><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_ym19_1_1483687514550_3970">.</span><span style="font-variant-ligatures: no-common-ligatures; color: #587ea8" id="yui_3_16_0_ym19_1_1483687514550_3971">standardInput</span><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_ym19_1_1483687514550_3972"> = pipeIn</span></div><div style="margin-top: 0px; margin-bottom: 0px; font-size: 12px; line-height: normal; font-family: Menlo; color: rgb(0, 119, 66);" id="yui_3_16_0_ym19_1_1483687514550_3973"><span style="font-variant-ligatures: no-common-ligatures; color: #000000" id="yui_3_16_0_ym19_1_1483687514550_3974">&nbsp; &nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_ym19_1_1483687514550_3975"><i id="yui_3_16_0_ym19_1_1483687514550_3976">// multiple inputs are separated by newline</i></span></div><div style="margin-top: 0px; margin-bottom: 0px; font-size: 12px; line-height: normal; font-family: Menlo;" id="yui_3_16_0_ym19_1_1483687514550_3977"><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_ym19_1_1483687514550_3978">&nbsp; &nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #35568a" id="yui_3_16_0_ym19_1_1483687514550_3979">if</span><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_ym19_1_1483687514550_3980"> </span><span style="font-variant-ligatures: no-common-ligatures; color: #35568a" id="yui_3_16_0_ym19_1_1483687514550_3981">let</span><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_ym19_1_1483687514550_3982"> input = input.</span><span style="font-variant-ligatures: no-common-ligatures; color: #587ea8" id="yui_3_16_0_ym19_1_1483687514550_3983">data</span><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_ym19_1_1483687514550_3984">(using: </span><span style="font-variant-ligatures: no-common-ligatures; color: #c35900" id="yui_3_16_0_ym19_1_1483687514550_3985">String</span><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_ym19_1_1483687514550_3986">.</span><span style="font-variant-ligatures: no-common-ligatures; color: #c35900" id="yui_3_16_0_ym19_1_1483687514550_3987">Encoding</span><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_ym19_1_1483687514550_3988">.</span><span style="font-variant-ligatures: no-common-ligatures; color: #587ea8" id="yui_3_16_0_ym19_1_1483687514550_3989">utf8</span><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_ym19_1_1483687514550_3990">) {</span></div><div style="margin-top: 0px; margin-bottom: 0px; font-size: 12px; line-height: normal; font-family: Menlo; color: rgb(88, 126, 168);" id="yui_3_16_0_ym19_1_1483687514550_3991"><span style="font-variant-ligatures: no-common-ligatures; color: #000000" id="yui_3_16_0_ym19_1_1483687514550_3992">&nbsp; &nbsp; &nbsp; &nbsp; pipeIn.</span><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_ym19_1_1483687514550_3993">fileHandleForWriting</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" id="yui_3_16_0_ym19_1_1483687514550_3994">.</span><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_ym19_1_1483687514550_3995">write</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" id="yui_3_16_0_ym19_1_1483687514550_3996">(input)</span></div><div style="margin-top: 0px; margin-bottom: 0px; font-size: 12px; line-height: normal; font-family: Menlo;" id="yui_3_16_0_ym19_1_1483687514550_3997"><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_ym19_1_1483687514550_3998">&nbsp; &nbsp; &nbsp; }</span></div><div style="margin-top: 0px; margin-bottom: 0px; font-size: 12px; line-height: normal; font-family: Menlo;" id="yui_3_16_0_ym19_1_1483687514550_3999"><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_ym19_1_1483687514550_4000">&nbsp; &nbsp; }</span></div><div style="margin-top: 0px; margin-bottom: 0px; font-size: 12px; line-height: normal; font-family: Menlo; min-height: 14px;" id="yui_3_16_0_ym19_1_1483687514550_4001"><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_ym19_1_1483687514550_4002">&nbsp;&nbsp; &nbsp;</span></div><div style="margin-top: 0px; margin-bottom: 0px; font-size: 12px; line-height: normal; font-family: Menlo;" id="yui_3_16_0_ym19_1_1483687514550_4003"><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_ym19_1_1483687514550_4004">&nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #35568a" id="yui_3_16_0_ym19_1_1483687514550_4005">let</span><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_ym19_1_1483687514550_4006"> pipeOut = </span><span style="font-variant-ligatures: no-common-ligatures; color: #c35900" id="yui_3_16_0_ym19_1_1483687514550_4007">Pipe</span><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_ym19_1_1483687514550_4008">()</span></div><div style="margin-top: 0px; margin-bottom: 0px; font-size: 12px; line-height: normal; font-family: Menlo;" id="yui_3_16_0_ym19_1_1483687514550_4009"><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_ym19_1_1483687514550_4010">&nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #35568a" id="yui_3_16_0_ym19_1_1483687514550_4011">self</span><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_ym19_1_1483687514550_4012">.</span><span style="font-variant-ligatures: no-common-ligatures; color: #587ea8" id="yui_3_16_0_ym19_1_1483687514550_4013">standardOutput</span><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_ym19_1_1483687514550_4014"> = pipeOut</span></div><div style="margin-top: 0px; margin-bottom: 0px; font-size: 12px; line-height: normal; font-family: Menlo; min-height: 14px;" id="yui_3_16_0_ym19_1_1483687514550_4015"><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_ym19_1_1483687514550_4016">&nbsp;&nbsp; &nbsp;</span></div><div style="margin-top: 0px; margin-bottom: 0px; font-size: 12px; line-height: normal; font-family: Menlo;" id="yui_3_16_0_ym19_1_1483687514550_4017"><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_ym19_1_1483687514550_4018">&nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #35568a" id="yui_3_16_0_ym19_1_1483687514550_4019">self</span><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_ym19_1_1483687514550_4020">.</span><span style="font-variant-ligatures: no-common-ligatures; color: #587ea8" id="yui_3_16_0_ym19_1_1483687514550_4021">arguments</span><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_ym19_1_1483687514550_4022"> = arguments</span></div><div style="margin-top: 0px; margin-bottom: 0px; font-size: 12px; line-height: normal; font-family: Menlo;" id="yui_3_16_0_ym19_1_1483687514550_4023"><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_ym19_1_1483687514550_4024">&nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #35568a" id="yui_3_16_0_ym19_1_1483687514550_4025">self</span><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_ym19_1_1483687514550_4026">.</span><span style="font-variant-ligatures: no-common-ligatures; color: #587ea8" id="yui_3_16_0_ym19_1_1483687514550_4027">launchPath</span><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_ym19_1_1483687514550_4028"> = command</span></div><div style="margin-top: 0px; margin-bottom: 0px; font-size: 12px; line-height: normal; font-family: Menlo; color: rgb(88, 126, 168);" id="yui_3_16_0_ym19_1_1483687514550_4029"><span style="font-variant-ligatures: no-common-ligatures; color: #000000" id="yui_3_16_0_ym19_1_1483687514550_4030">&nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #35568a" id="yui_3_16_0_ym19_1_1483687514550_4031">self</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" id="yui_3_16_0_ym19_1_1483687514550_4032">.</span><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_ym19_1_1483687514550_4033">currentDirectoryPath</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" id="yui_3_16_0_ym19_1_1483687514550_4034"> = currentDir</span></div><div style="margin-top: 0px; margin-bottom: 0px; font-size: 12px; line-height: normal; font-family: Menlo; min-height: 14px;" id="yui_3_16_0_ym19_1_1483687514550_4035"><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_ym19_1_1483687514550_4036">&nbsp;&nbsp; &nbsp;</span></div><div style="margin-top: 0px; margin-bottom: 0px; font-size: 12px; line-height: normal; font-family: Menlo;" id="yui_3_16_0_ym19_1_1483687514550_4037"><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_ym19_1_1483687514550_4038">&nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #35568a" id="yui_3_16_0_ym19_1_1483687514550_4039">self</span><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_ym19_1_1483687514550_4040">.</span><span style="font-variant-ligatures: no-common-ligatures; color: #587ea8" id="yui_3_16_0_ym19_1_1483687514550_4041">launch</span><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_ym19_1_1483687514550_4042">()</span></div><div style="margin-top: 0px; margin-bottom: 0px; font-size: 12px; line-height: normal; font-family: Menlo; color: rgb(88, 126, 168);" id="yui_3_16_0_ym19_1_1483687514550_4043"><span style="font-variant-ligatures: no-common-ligatures; color: #000000" id="yui_3_16_0_ym19_1_1483687514550_4044">&nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #35568a" id="yui_3_16_0_ym19_1_1483687514550_4045">let</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" id="yui_3_16_0_ym19_1_1483687514550_4046"> output = pipeOut.</span><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_ym19_1_1483687514550_4047">fileHandleForReading</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" id="yui_3_16_0_ym19_1_1483687514550_4048">.</span><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_ym19_1_1483687514550_4049">readDataToEndOfFile</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" id="yui_3_16_0_ym19_1_1483687514550_4050">()</span></div><div style="margin-top: 0px; margin-bottom: 0px; font-size: 12px; line-height: normal; font-family: Menlo; color: rgb(88, 126, 168);" id="yui_3_16_0_ym19_1_1483687514550_4051"><span style="font-variant-ligatures: no-common-ligatures; color: #000000" id="yui_3_16_0_ym19_1_1483687514550_4052">&nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #35568a" id="yui_3_16_0_ym19_1_1483687514550_4053">self</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" id="yui_3_16_0_ym19_1_1483687514550_4054">.</span><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_ym19_1_1483687514550_4055">waitUntilExit</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" id="yui_3_16_0_ym19_1_1483687514550_4056">()</span></div><div style="margin-top: 0px; margin-bottom: 0px; font-size: 12px; line-height: normal; font-family: Menlo; min-height: 14px;" id="yui_3_16_0_ym19_1_1483687514550_4057"><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_ym19_1_1483687514550_4058">&nbsp;&nbsp; &nbsp;</span></div><div style="margin-top: 0px; margin-bottom: 0px; font-size: 12px; line-height: normal; font-family: Menlo;" id="yui_3_16_0_ym19_1_1483687514550_4059"><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_ym19_1_1483687514550_4060">&nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #35568a" id="yui_3_16_0_ym19_1_1483687514550_4061">return</span><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_ym19_1_1483687514550_4062"> </span><span style="font-variant-ligatures: no-common-ligatures; color: #c35900" id="yui_3_16_0_ym19_1_1483687514550_4063">String</span><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_ym19_1_1483687514550_4064">(data: output, encoding: </span><span style="font-variant-ligatures: no-common-ligatures; color: #c35900" id="yui_3_16_0_ym19_1_1483687514550_4065">String</span><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_ym19_1_1483687514550_4066">.</span><span style="font-variant-ligatures: no-common-ligatures; color: #c35900" id="yui_3_16_0_ym19_1_1483687514550_4067">Encoding</span><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_ym19_1_1483687514550_4068">(rawValue: </span><span style="font-variant-ligatures: no-common-ligatures; color: #c35900" id="yui_3_16_0_ym19_1_1483687514550_4069">String</span><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_ym19_1_1483687514550_4070">.</span><span style="font-variant-ligatures: no-common-ligatures; color: #c35900" id="yui_3_16_0_ym19_1_1483687514550_4071">Encoding</span><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_ym19_1_1483687514550_4072">.</span><span style="font-variant-ligatures: no-common-ligatures; color: #587ea8" id="yui_3_16_0_ym19_1_1483687514550_4073">utf8</span><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_ym19_1_1483687514550_4074">.</span><span style="font-variant-ligatures: no-common-ligatures; color: #587ea8" id="yui_3_16_0_ym19_1_1483687514550_4075">rawValue</span><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_ym19_1_1483687514550_4076">))!</span></div><div style="margin-top: 0px; margin-bottom: 0px; font-size: 12px; line-height: normal; font-family: Menlo;" id="yui_3_16_0_ym19_1_1483687514550_4077"><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_ym19_1_1483687514550_4078">&nbsp; }</span></div><div style="margin-top: 0px; margin-bottom: 0px; font-size: 12px; line-height: normal; font-family: Menlo;" id="yui_3_16_0_ym19_1_1483687514550_4079"><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_ym19_1_1483687514550_4080">}</span></div><div style="margin-top: 0px; margin-bottom: 0px; font-size: 12px; line-height: normal; font-family: Menlo; min-height: 14px;" id="yui_3_16_0_ym19_1_1483687514550_4081"><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_ym19_1_1483687514550_4082"></span><br id="yui_3_16_0_ym19_1_1483687514550_4083"></div><div style="margin-top: 0px; margin-bottom: 0px; font-size: 12px; line-height: normal; font-family: Menlo; color: rgb(0, 119, 66);" id="yui_3_16_0_ym19_1_1483687514550_4084"><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_ym19_1_1483687514550_4085"><i id="yui_3_16_0_ym19_1_1483687514550_4086">//print(Process().execute(command: "/bin/ls", arguments: ["-l"]))</i></span></div><div style="margin-top: 0px; margin-bottom: 0px; font-size: 12px; line-height: normal; font-family: Menlo; min-height: 14px;" id="yui_3_16_0_ym19_1_1483687514550_4087"><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_ym19_1_1483687514550_4088"></span><br id="yui_3_16_0_ym19_1_1483687514550_4089"></div><div style="margin-top: 0px; margin-bottom: 0px; font-size: 12px; line-height: normal; font-family: Menlo;" id="yui_3_16_0_ym19_1_1483687514550_4090"><span style="font-variant-ligatures: no-common-ligatures; color: #35568a" id="yui_3_16_0_ym19_1_1483687514550_4091">var</span><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_ym19_1_1483687514550_4092"> cmd = </span><span style="font-variant-ligatures: no-common-ligatures; color: #c35900" id="yui_3_16_0_ym19_1_1483687514550_4093">Process</span><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_ym19_1_1483687514550_4094">()</span></div><div style="margin-top: 0px; margin-bottom: 0px; font-size: 12px; line-height: normal; font-family: Menlo; min-height: 14px;" id="yui_3_16_0_ym19_1_1483687514550_4095"><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_ym19_1_1483687514550_4096"></span><br id="yui_3_16_0_ym19_1_1483687514550_4097"></div><div style="margin-top: 0px; margin-bottom: 0px; font-size: 12px; line-height: normal; font-family: Menlo; color: rgb(232, 35, 0);" id="yui_3_16_0_ym19_1_1483687514550_4098"><span style="font-variant-ligatures: no-common-ligatures; color: #587ea8" id="yui_3_16_0_ym19_1_1483687514550_4099">print</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" id="yui_3_16_0_ym19_1_1483687514550_4100">(</span><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_ym19_1_1483687514550_4101">"Starting..."</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" id="yui_3_16_0_ym19_1_1483687514550_4102">)</span></div><div style="margin-top: 0px; margin-bottom: 0px; font-size: 12px; line-height: normal; font-family: Menlo; min-height: 14px;" id="yui_3_16_0_ym19_1_1483687514550_4103"><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_ym19_1_1483687514550_4104"></span><br id="yui_3_16_0_ym19_1_1483687514550_4105"></div><div style="margin-top: 0px; margin-bottom: 0px; font-size: 12px; line-height: normal; font-family: Menlo; color: rgb(88, 126, 168);" id="yui_3_16_0_ym19_1_1483687514550_4106"><span style="font-variant-ligatures: no-common-ligatures; color: #c35900" id="yui_3_16_0_ym19_1_1483687514550_4107">DispatchQueue</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" id="yui_3_16_0_ym19_1_1483687514550_4108">.</span><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_ym19_1_1483687514550_4109">global</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" id="yui_3_16_0_ym19_1_1483687514550_4110">(qos: .</span><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_ym19_1_1483687514550_4111">default</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" id="yui_3_16_0_ym19_1_1483687514550_4112">).</span><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_ym19_1_1483687514550_4113">async</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" id="yui_3_16_0_ym19_1_1483687514550_4114"> {</span></div><div style="margin-top: 0px; margin-bottom: 0px; font-size: 12px; line-height: normal; font-family: Menlo; color: rgb(232, 35, 0);" id="yui_3_16_0_ym19_1_1483687514550_4115"><span style="font-variant-ligatures: no-common-ligatures; color: #000000" id="yui_3_16_0_ym19_1_1483687514550_4116">&nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #587ea8" id="yui_3_16_0_ym19_1_1483687514550_4117">print</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" id="yui_3_16_0_ym19_1_1483687514550_4118">(</span><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_ym19_1_1483687514550_4119">"Executing..."</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" id="yui_3_16_0_ym19_1_1483687514550_4120">)</span></div><div style="margin-top: 0px; margin-bottom: 0px; font-size: 12px; line-height: normal; font-family: Menlo;" id="yui_3_16_0_ym19_1_1483687514550_4121"><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_ym19_1_1483687514550_4122">&nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #35568a" id="yui_3_16_0_ym19_1_1483687514550_4123">let</span><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_ym19_1_1483687514550_4124"> s = </span><span style="font-variant-ligatures: no-common-ligatures; color: #587ea8" id="yui_3_16_0_ym19_1_1483687514550_4125">cmd</span><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_ym19_1_1483687514550_4126">.</span><span style="font-variant-ligatures: no-common-ligatures; color: #587ea8" id="yui_3_16_0_ym19_1_1483687514550_4127">execute</span><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_ym19_1_1483687514550_4128">(command: </span><span style="font-variant-ligatures: no-common-ligatures; color: #e82300" id="yui_3_16_0_ym19_1_1483687514550_4129">"/bin/ls"</span><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_ym19_1_1483687514550_4130">, arguments: [</span><span style="font-variant-ligatures: no-common-ligatures; color: #e82300" id="yui_3_16_0_ym19_1_1483687514550_4131">"-l"</span><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_ym19_1_1483687514550_4132">])</span></div><div style="margin-top: 0px; margin-bottom: 0px; font-size: 12px; line-height: normal; font-family: Menlo;" id="yui_3_16_0_ym19_1_1483687514550_4133"><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_ym19_1_1483687514550_4134">&nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #587ea8" id="yui_3_16_0_ym19_1_1483687514550_4135">print</span><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_ym19_1_1483687514550_4136">(s)</span></div><div style="margin-top: 0px; margin-bottom: 0px; font-size: 12px; line-height: normal; font-family: Menlo;" id="yui_3_16_0_ym19_1_1483687514550_4137"><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_ym19_1_1483687514550_4138">}</span></div><div style="margin-top: 0px; margin-bottom: 0px; font-size: 12px; line-height: normal; font-family: Menlo; min-height: 14px;" id="yui_3_16_0_ym19_1_1483687514550_4139"><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_ym19_1_1483687514550_4140"></span><br id="yui_3_16_0_ym19_1_1483687514550_4141"></div><div style="margin-top: 0px; margin-bottom: 0px; font-size: 12px; line-height: normal; font-family: Menlo;" id="yui_3_16_0_ym19_1_1483687514550_4142"><span style="font-variant-ligatures: no-common-ligatures; color: #c35900" id="yui_3_16_0_ym19_1_1483687514550_4143">DispatchQueue</span><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_ym19_1_1483687514550_4144">.</span><span style="font-variant-ligatures: no-common-ligatures; color: #587ea8" id="yui_3_16_0_ym19_1_1483687514550_4145">global</span><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_ym19_1_1483687514550_4146">(qos: .</span><span style="font-variant-ligatures: no-common-ligatures; color: #587ea8" id="yui_3_16_0_ym19_1_1483687514550_4147">default</span><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_ym19_1_1483687514550_4148">).</span><span style="font-variant-ligatures: no-common-ligatures; color: #587ea8" id="yui_3_16_0_ym19_1_1483687514550_4149">asyncAfter</span><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_ym19_1_1483687514550_4150">(deadline: </span><span style="font-variant-ligatures: no-common-ligatures; color: #c35900" id="yui_3_16_0_ym19_1_1483687514550_4151">DispatchTime</span><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_ym19_1_1483687514550_4152">.</span><span style="font-variant-ligatures: no-common-ligatures; color: #587ea8" id="yui_3_16_0_ym19_1_1483687514550_4153">now</span><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_ym19_1_1483687514550_4154">() + .</span><span style="font-variant-ligatures: no-common-ligatures; color: #587ea8" id="yui_3_16_0_ym19_1_1483687514550_4155">seconds</span><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_ym19_1_1483687514550_4156">(</span><span style="font-variant-ligatures: no-common-ligatures; color: #0433ff" id="yui_3_16_0_ym19_1_1483687514550_4157">5</span><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_ym19_1_1483687514550_4158">)) {</span></div><div style="margin-top: 0px; margin-bottom: 0px; font-size: 12px; line-height: normal; font-family: Menlo; color: rgb(88, 126, 168);" id="yui_3_16_0_ym19_1_1483687514550_4159"><span style="font-variant-ligatures: no-common-ligatures; color: #000000" id="yui_3_16_0_ym19_1_1483687514550_4160">&nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #35568a" id="yui_3_16_0_ym19_1_1483687514550_4161">if</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" id="yui_3_16_0_ym19_1_1483687514550_4162"> </span><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_ym19_1_1483687514550_4163">cmd</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" id="yui_3_16_0_ym19_1_1483687514550_4164">.</span><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_ym19_1_1483687514550_4165">isRunning</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" id="yui_3_16_0_ym19_1_1483687514550_4166"> {</span></div><div style="margin-top: 0px; margin-bottom: 0px; font-size: 12px; line-height: normal; font-family: Menlo; color: rgb(232, 35, 0);" id="yui_3_16_0_ym19_1_1483687514550_4167"><span style="font-variant-ligatures: no-common-ligatures; color: #000000" id="yui_3_16_0_ym19_1_1483687514550_4168">&nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #587ea8" id="yui_3_16_0_ym19_1_1483687514550_4169">print</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" id="yui_3_16_0_ym19_1_1483687514550_4170">(</span><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_ym19_1_1483687514550_4171">"Terminating..."</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" id="yui_3_16_0_ym19_1_1483687514550_4172">)</span></div><div style="margin-top: 0px; margin-bottom: 0px; font-size: 12px; line-height: normal; font-family: Menlo; color: rgb(88, 126, 168);" id="yui_3_16_0_ym19_1_1483687514550_4173"><span style="font-variant-ligatures: no-common-ligatures; color: #000000" id="yui_3_16_0_ym19_1_1483687514550_4174">&nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_ym19_1_1483687514550_4175">cmd</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" id="yui_3_16_0_ym19_1_1483687514550_4176">.</span><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_ym19_1_1483687514550_4177">terminate</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" id="yui_3_16_0_ym19_1_1483687514550_4178">()</span></div><div style="margin-top: 0px; margin-bottom: 0px; font-size: 12px; line-height: normal; font-family: Menlo;" id="yui_3_16_0_ym19_1_1483687514550_4179"><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_ym19_1_1483687514550_4180">&nbsp; }</span></div><div style="margin-top: 0px; margin-bottom: 0px; font-size: 12px; line-height: normal; font-family: Menlo;" id="yui_3_16_0_ym19_1_1483687514550_4181"><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_ym19_1_1483687514550_4182">}</span></div><div style="margin-top: 0px; margin-bottom: 0px; font-size: 12px; line-height: normal; font-family: Menlo; min-height: 14px;" id="yui_3_16_0_ym19_1_1483687514550_4183"><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_ym19_1_1483687514550_4184"></span><br id="yui_3_16_0_ym19_1_1483687514550_4185"></div><div style="margin-top: 0px; margin-bottom: 0px; font-size: 12px; line-height: normal; font-family: Menlo;" id="yui_3_16_0_ym19_1_1483687514550_3008">















































</div><div style="margin-top: 0px; margin-bottom: 0px; font-size: 12px; line-height: normal; font-family: Menlo; color: rgb(232, 35, 0);" dir="ltr" id="yui_3_16_0_ym19_1_1483687514550_4186"><span style="font-variant-ligatures: no-common-ligatures; color: #587ea8" id="yui_3_16_0_ym19_1_1483687514550_4187">print</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" id="yui_3_16_0_ym19_1_1483687514550_4188">(</span><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_ym19_1_1483687514550_4189">"Done."</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" id="yui_3_16_0_ym19_1_1483687514550_4190">)</span></div><div></div><div id="yui_3_16_0_ym19_1_1483687514550_2403">&nbsp;</div><div class="signature" id="yui_3_16_0_ym19_1_1483687514550_2288"><div id="yui_3_16_0_ym19_1_1483687514550_2328"><br></div><div id="yui_3_16_0_ym19_1_1483687514550_2328" dir="ltr">The code doesn't work as expected. The&nbsp;<span style="font-family: Menlo; font-size: 12px; font-variant-ligatures: no-common-ligatures;" id="yui_3_16_0_ym19_1_1483687514550_4226">execute(</span><span style="font-family: Menlo; font-size: 12px; font-variant-ligatures: no-common-ligatures;" id="yui_3_16_0_ym19_1_1483687514550_4238">)</span>&nbsp;function itself works fine (uncomment the call in the middle of the code), but I don't know why it doesn't work if it's called from within&nbsp;<span style="color: rgb(195, 89, 0); font-family: Menlo; font-size: 12px;" id="yui_3_16_0_ym19_1_1483687514550_4246">DispatchQueue</span>&nbsp;closure. Even if I call a much more simple function —like a for loop— it doesn't work consistenly, sometimes the loop is completed, but other times it's not.</div><div id="yui_3_16_0_ym19_1_1483687514550_2328" dir="ltr"><br></div><div id="yui_3_16_0_ym19_1_1483687514550_2328" dir="ltr">Google didn't really help me because this topic is pretty rare I suppose. Could anyone enlight me, how to make the code works as I expected? What did I do wrong?</div><div id="yui_3_16_0_ym19_1_1483687514550_2328" dir="ltr"><br></div><div id="yui_3_16_0_ym19_1_1483687514550_2328" dir="ltr">Thank you.</div><div id="yui_3_16_0_ym19_1_1483687514550_2328" dir="ltr"><br></div><div id="yui_3_16_0_ym19_1_1483687514550_2328" dir="ltr">Regards,</div><div id="yui_3_16_0_ym19_1_1483687514550_2328"><br></div><div id="yui_3_16_0_ym19_1_1483687514550_2328"><br></div>–Mr Bee<div id="yui_3_16_0_ym19_1_1483687514550_4403"><br></div></div></div></body></html>