title: C - infinite read from cat in Device file
body: <p>I've been having some headache with infinite reads from cat (cat doesn’t close because it doesn’t receive end of function from my read function. How can I implement an end of read so that reading the file with cat will only produce 1 output per command in the terminal? </p>
  
  <p>function. This is the kernel read() function I've written: </p>
  
  <pre><code>static ssize_t dev_read(struct file *file, char *buf, size_t count, loff_t *ppos)
  {
  char tmp_buf[MAX_BUF_SIZE]; //defined as 100
  int bLen=0;
  sprintf(tmp_buf, "Some message");
  bLen = strlen(tmp_buf);
  
  if(copy_to_user(buf,tmp_buf, bLen)){
       return -EFAULT;
  }
  
   return bLen;
   }
  </code></pre>