title: Mac OS Cocoa application to stress the CPU
body: <p>I am trying to build an UI application having 2 buttons, Start and Stop.</p>
  
  <p>Clicking the Start button should run the terminal command:</p>
  
  <pre><code>yes &gt; /dev/null &amp; yes &gt; /dev/null &amp; yes &gt; /dev/null &amp;
  </code></pre>
  
  <p>The Stop button should run:</p>
  
  <pre><code>killall yes
  </code></pre>
  
  <p>I am also wondering if the app could be run on every mac OS.</p>
  
  <hr>
  
  <p>My code</p>
  
  <pre><code>import Cocoa
  
  @NSApplicationMain
  
  class AppDelegate: NSObject, NSApplicationDelegate {
  
      @IBOutlet weak var window: NSWindow!
  
      func applicationDidFinishLaunching(_ aNotification: Notification) {
  
      }
  
      func applicationWillTerminate(_ aNotification: Notification) {
  
      }
  
      @IBAction func StartStress(_ sender: NSButton) {
  
          let path = "/varun-kaddichha$/Desktop/MacStressTest/stress.sh"
          let arguments = ["/varun-kaddichha$/Desktop/MacStressTest/stress.sh"]
          sender.isEnabled = false
          let task = Process.launchedProcess(launchPath: path, arguments: arguments)
          task.waitUntilExit()
          sender.isEnabled = true
      }
  
  }
  </code></pre>
  
  <p>My bash file </p>
  
  <pre><code>#! /bin/bash
  
  do shell script "yes &gt; /dev/null &amp; yes &gt; /dev/null &amp; yes &gt; /dev/null &amp; yes &gt; /dev/null &amp; yes &gt; /dev/null &amp; yes &gt; /dev/null &amp; "
  </code></pre>