Open System Services Programmer's Guide
cpu, STDIN_FILENO, errno);
exit(1);
}
else if (bytesread == 0) /* check for input closed */
{
ffprintf(stderr, "dserver [cpu %d] - "
"stopping [input closed]\n",
cpu);
exit(1);
}
else /* data received */
{
/* give progress message */
msg_buff[bytesread] = '\0'; /* guarantee string NULL-terminated */
fprintf(stderr, "dserver [cpu %d] - "
"message received on fd %d = %s",
cpu, STDIN_FILENO, msg_buff);
/* echo on stdout */
if (write(STDOUT_FILENO, msg_buff, bytesread) < 0)
{
fprintf(stderr, "dserver [cpu %d] - "
"write(fd %d) failed [errno %d]\n",
cpu, STDOUT_FILENO, errno);
exit(1);
}
}
} /* end while (1) */
}
Process Execution Priority-Control Functions
You can change the process scheduling priority, called the nice value, with the nice() function.
Example 28 provides sample code to demonstrate the use of the getpriority() function to
determine the process priority of the processes that are members of the specified group. The sample
code also demonstrates the use of nice() to change the current process priority by the increment
specified in the command line.
Common and Unique Characteristics 111