title: Control the LED blinking via on / off in a c program
body: <p>I'm looking for suggestion and a bit of guidance if any of you had a similar problem.
  I have 2 LED (green, red, dedicated pins) that I can control. The available commands are On / Off / Toggle.</p>
  <p>I have written a small program in C to control the LEDs, and I can run it simply in terminal FreeBSD:</p>
  <ul>
  <li>led 1 : OFF green LED</li>
  <li>led 2 : ON green LED</li>
  <li>led 3 : blink green LED</li>
  <li>led 4 : OFF red LED</li>
  <li>led 5 : ON red LED</li>
  <li>led 6 : blink red LED</li>
  </ul>
  <p>Now when it comes to blinking it is a bit more complicated, because it stays in the loop. I can use a timer, but that's not very useful to me ('cause I don't know for how long I will need it blinking).</p>
  <pre><code>while (1) {
    gpio_pin_high(handle, pin);
    sleep(1);
    gpio_pin_low(handle, pin);
    sleep(1);
  }
  </code></pre>
  <p>My goal is to use LED blinking when a process starts - let's say it waiting to connect to WiFi. And when connected, use LED on.</p>
  <p>I guess I can use fork() only for the blinking function, and when I want to turn LED on after having it blinking, I should check for the child process, stop and clean it up, and then call led_on function.</p>
  <p>Thank you in advance for any ideas</p>