child.c: consistent indentation
This commit is contained in:
parent
9a53cd2c48
commit
d4b2abb5f9
22
src/child.c
22
src/child.c
@ -34,7 +34,8 @@ int child_writer_dead_handler(void) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void child_process_score_writer(int chfd, gchar *score_file) {
|
||||
void child_process_score_writer(int chfd, gchar *score_file)
|
||||
{
|
||||
fd_set rfds;
|
||||
int i;
|
||||
int fd=-1;
|
||||
@ -44,10 +45,12 @@ void child_process_score_writer(int chfd, gchar *score_file) {
|
||||
struct flock lockinfo;
|
||||
gchar *score_file_full = g_strconcat(LOCALSTATEDIR, score_file, NULL);
|
||||
|
||||
while(1) {
|
||||
while (1)
|
||||
{
|
||||
FD_ZERO(&rfds);
|
||||
FD_SET(chfd, &rfds);
|
||||
if(select(chfd + 1, &rfds, NULL, NULL, NULL) > 0) {
|
||||
if (select(chfd + 1, &rfds, NULL, NULL, NULL) > 0)
|
||||
{
|
||||
if (read(chfd, &sz, sizeof(sz)) <= 0) {
|
||||
exit(0);
|
||||
}
|
||||
@ -68,7 +71,9 @@ void child_process_score_writer(int chfd, gchar *score_file) {
|
||||
i = 0;
|
||||
while (1) {
|
||||
lockinfo.l_type=F_WRLCK;
|
||||
if(!fcntl(fd, F_SETLK, &lockinfo)) break;
|
||||
if (!fcntl(fd, F_SETLK, &lockinfo)) {
|
||||
break;
|
||||
}
|
||||
if (i >= 3) {
|
||||
close(fd);
|
||||
fd = -1;
|
||||
@ -89,15 +94,15 @@ void child_process_score_writer(int chfd, gchar *score_file) {
|
||||
if (fd != -1) {
|
||||
close(fd);
|
||||
} else {
|
||||
/* FIXME: here should be some sort of error
|
||||
reporting to parent */
|
||||
/* FIXME: here should be some sort of error reporting to parent */
|
||||
}
|
||||
sigprocmask(SIG_UNBLOCK, &sset, NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void sigchld_handler(int param) {
|
||||
static void sigchld_handler(int param)
|
||||
{
|
||||
pid_t ret = waitpid(0, NULL, WNOHANG);
|
||||
|
||||
if (ret > 0) { /* score writer process killed by bastards! */
|
||||
@ -105,7 +110,8 @@ static void sigchld_handler(int param) {
|
||||
}
|
||||
}
|
||||
|
||||
int child_setup(gchar *score_file) {
|
||||
int child_setup(gchar *score_file)
|
||||
{
|
||||
pid_t pid;
|
||||
struct sigaction sact;
|
||||
int sfds[2];
|
||||
|
Loading…
x
Reference in New Issue
Block a user