- status = swrite ("STATS\n", strlen ("STATS\n"));
- if (status != 0)
- {
- pthread_mutex_unlock (&lock);
- return (status);
- }
-
- status = sread (buffer, sizeof (buffer));
- if (status < 0)
- {
- status = errno;
- pthread_mutex_unlock (&lock);
- return (status);
- }
- else if (status == 0)
- {
- pthread_mutex_unlock (&lock);
- return (ENODATA);
- }
-
- pthread_mutex_unlock (&lock);
-
- /* Assert NULL termination */
- buffer_size = (size_t) status;
- if (buffer[buffer_size - 1] != 0)
- {
- if (buffer_size < sizeof (buffer))
- {
- buffer[buffer_size] = 0;
- buffer_size++;
- }
- else
- {
- return (ENOBUFS);
- }
- }