title: Restarting an endless while loop upon a mouse event?
body: <p>I am aiming a simple code which looks like this:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;unistd.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;string.h&gt;
  #include &lt;fcntl.h&gt;
  #include &lt;poll.h&gt;
  #include &lt;linux/input.h&gt;
  
  int main()
  {
      int fd, bytes;
      unsigned char data[3];
      fd = open("/dev/input/mice", O_RDWR);
      int left;
  
      while(1)
      {    
          bytes = read(fd, data, sizeof(data));
  
          if(bytes &gt; 0)
          {
              left = data[0] &amp; 0x1;
              right = data[0] &amp; 0x2;
  
              if(left==1){
              goto reset_EVENT;
              }           
          }
  
          reset_EVENT:
  
          printf("hey 1");
          sleep(1);   
          printf("hey 2");
          sleep(1);
          printf("hey 3");
          sleep(1);
      }
      return 0;
  }
  </code></pre>
  
  <p>My goal here is to restart the print sequence from "hey 1" immediately when left mouse is clicked.
  However, I am not able to achieve this without using "if" conditions before every sleep. a "goto" is not working for me across different functions too.
  Can anyone suggest an optimal solution for this one please ?</p>