title: cmd.Run() hangs forever in golang on Macos when the screen is locked/off
body: <p>I am running a golang app on Macos. It has some codes like the following:</p>
  
  <pre><code>for {
      time.Sleep(time.Second * 5)
      cmd := exec.Command("/usr/bin/osascript", "-e", `display dialog "hello" with title "hello"`)
      err := cmd.Run()
  }
  </code></pre>
  
  <p>It works fine if I don't lock the screen (when the screen is always on). But the code <code>err := cmd.Run()</code> will hang forever if the screen is locked and off when that line executes. When I unlock the screen (turn it on), the <code>for</code> loop just hangs there forever and will never continue its execution. </p>
  
  <p>I am not sure if this issue belongs to golang or how MacOS handles osascript. Can anyone please tell me how to workaround it? Thanks a lot.</p>
  
  <p>PS: I use the same code in Linux and replace <code>/usr/bin/osascript</code> to <code>/usr/bin/xmessage</code> and this always works fine without any problems even if the screen is locked/off in Linux. </p>
  
  <p><strong>Edited:</strong></p>
  
  <p>My solution, use chrome instead: </p>
  
  <pre><code>cmd := exec.Command(`/Applications/Google Chrome.app/Contents/MacOS/Google Chrome`, "-new-window", "/path/hello.html")
  </code></pre>