title: execute functions in specific order
body: <p>I have the following function</p>
  <pre><code>func (c *Connection) ConnectVpn() error {
  
      cmd := exec.Command(c.Command, c.Args...)
  
      var password bytes.Buffer
      password.WriteString(os.Getenv(&quot;PASSWORD&quot;))
  
      cmd.Stdin = &amp;password
      cmd.Stdout = os.Stdout
      cmd.Stderr = os.Stderr
  
      err := cmd.Start()
      if err != nil {
          return err
      }
  
      return err
  
  }
  </code></pre>
  <p>This function call the <code>openconnect</code> binary and connects in a private vpn to be able to reach a specific server (it works fine).</p>
  <p>The problem is that when I call <code>cmd.Start()</code> it creates a thread and allows me to execute the another function named <code>checkCertificate()</code> but then this function is called before the vpn connects so it fails.
  When I try to let the VPN connects and use <code>cmd.RUN()</code> this process do not run on background so the process never finish and it never tells to <code>cmd.Wait()</code> it finished because it shouldn't finish.</p>
  <pre><code>days, err := domain.CheckCertificate()
          if err != nil {
              log.Fatalln(err)
          }
  </code></pre>
  <p>I have tried to use channels to try to sync the results between them but when I do this the <code>checkCertificate()</code> function keeps being executed before the VPN executes and I can't reach the server I need.</p>
  <p>Any idea in how I could let the <code>ConnectVPN()</code> function be running on foreground and even so send some signal to my other function to say vpn is connected now, please run?</p>
  <p>I have tried to send the <code>openconnect</code> to background with <code>cmd.Process.Signal(syscall.SIGTSTP)</code> but when I bring it back it breaks the main function.</p>