From c1520e15ff35fa7ec19b6aa999362adef5963b9d Mon Sep 17 00:00:00 2001 From: Lee Verberne Date: Tue, 22 Nov 2016 23:13:03 +0000 Subject: [PATCH] Address style comments for pause.c Run clang-format on the C files and capitalize error messages. --- build-tools/pause/orphan.c | 25 +++++++++++++------------ build/pause/pause.c | 35 +++++++++++++++++++---------------- 2 files changed, 32 insertions(+), 28 deletions(-) diff --git a/build-tools/pause/orphan.c b/build-tools/pause/orphan.c index b2d1a6cd58b..07f490de91d 100644 --- a/build-tools/pause/orphan.c +++ b/build-tools/pause/orphan.c @@ -20,16 +20,17 @@ limitations under the License. #include int main() { - pid_t pid; - pid = fork(); - if ( pid == 0 ) { - while ( getppid() > 1 ); - printf("Child exiting: pid=%d ppid=%d\n", getpid(), getppid()); - return 0; - } else if ( pid > 0 ) { - printf("Parent exiting: pid=%d ppid=%d\n", getpid(), getppid()); - return 0; - } - perror("Could not create child"); - return 1; + pid_t pid; + pid = fork(); + if (pid == 0) { + while (getppid() > 1) + ; + printf("Child exiting: pid=%d ppid=%d\n", getpid(), getppid()); + return 0; + } else if (pid > 0) { + printf("Parent exiting: pid=%d ppid=%d\n", getpid(), getppid()); + return 0; + } + perror("Could not create child"); + return 1; } diff --git a/build/pause/pause.c b/build/pause/pause.c index cdf6637ce0c..4dac4d1b5af 100644 --- a/build/pause/pause.c +++ b/build/pause/pause.c @@ -22,28 +22,31 @@ limitations under the License. #include static void sigdown(int signo) { - psignal(signo, "shutting down, got signal"); - exit(0); + psignal(signo, "Shutting down, got signal"); + exit(0); } static void sigreap(int signo) { - while (waitpid(-1, NULL, WNOHANG) > 0); + while (waitpid(-1, NULL, WNOHANG) > 0) + ; } int main() { - if (getpid() != 1) { - fprintf(stderr, "Warning: pause should be the first process in a pod\n"); - } + if (getpid() != 1) + fprintf(stderr, "Warning: pause should be the first process in a pod\n"); - if (sigaction(SIGINT, &(struct sigaction){.sa_handler = sigdown}, NULL) < 0) - return 1; - if (sigaction(SIGTERM, &(struct sigaction){.sa_handler = sigdown}, NULL) < 0) - return 2; - if (sigaction(SIGCHLD, &(struct sigaction){.sa_handler = sigreap, .sa_flags = SA_NOCLDSTOP}, NULL) < 0) - return 3; - sigaction(SIGKILL, &(struct sigaction){.sa_handler = sigdown}, NULL); + if (sigaction(SIGINT, &(struct sigaction){.sa_handler = sigdown}, NULL) < 0) + return 1; + if (sigaction(SIGTERM, &(struct sigaction){.sa_handler = sigdown}, NULL) < 0) + return 2; + if (sigaction(SIGCHLD, &(struct sigaction){.sa_handler = sigreap, + .sa_flags = SA_NOCLDSTOP}, + NULL) < 0) + return 3; + sigaction(SIGKILL, &(struct sigaction){.sa_handler = sigdown}, NULL); - for (;;) pause(); - fprintf(stderr, "error: infinite loop terminated\n"); - return 42; + for (;;) + pause(); + fprintf(stderr, "Error: infinite loop terminated\n"); + return 42; }