#include <string.h> /* strcpy, strcmp */
#include <stdlib.h> /* exit, atol, atoi */
#include <sys/time.h> /* setitimer, settimeofday, gettimeofday */
+#include <time.h> /* time */
#include <signal.h> /* signal */
#include <sched.h> /* sched_setscheduler, sched_get_priority_min,*/
/* sched_get_priority_max */
while((readBytes = read(fdProfile, readBuf, sizeof(readBuf))) > 0)
{
- write(fdSnapshot, readBuf, readBytes);
+ int writeBytes = write(fdSnapshot, readBuf, readBytes);
+ if (writeBytes != readBytes) {
+ perror("write error");
+ break;
+ }
}
close(fdSnapshot);
if(DoRead)
{
- read(Fd2, tmpBuf, 1);
+ cntr = read(Fd2, tmpBuf, 1);
+ if (cntr < 0)
+ perror("read error");
lseek(Fd2, 0, SEEK_SET); /* back to start */
}
if(err < bytes)
{
- printf("Write Error at line %i! Wanted to write %i bytes, but wrote only %i bytes.\n",
+ printf("Write Error at line %i! Wanted to write %zu bytes, but wrote only %i bytes.\n",
lineNo, bytes, err);
perror("Write did not complete. Error. Bye:"); /* show error from errno. */
exit(1);