mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-04 04:08:16 +00:00 
			
		
		
		
	Address style comments for pause.c
Run clang-format on the C files and capitalize error messages.
This commit is contained in:
		@@ -23,7 +23,8 @@ int main() {
 | 
			
		||||
  pid_t pid;
 | 
			
		||||
  pid = fork();
 | 
			
		||||
  if (pid == 0) {
 | 
			
		||||
		while ( getppid() > 1 );
 | 
			
		||||
    while (getppid() > 1)
 | 
			
		||||
      ;
 | 
			
		||||
    printf("Child exiting: pid=%d ppid=%d\n", getpid(), getppid());
 | 
			
		||||
    return 0;
 | 
			
		||||
  } else if (pid > 0) {
 | 
			
		||||
 
 | 
			
		||||
@@ -22,28 +22,31 @@ limitations under the License.
 | 
			
		||||
#include <unistd.h>
 | 
			
		||||
 | 
			
		||||
static void sigdown(int signo) {
 | 
			
		||||
	psignal(signo, "shutting down, got signal");
 | 
			
		||||
  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) {
 | 
			
		||||
  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)
 | 
			
		||||
  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");
 | 
			
		||||
  for (;;)
 | 
			
		||||
    pause();
 | 
			
		||||
  fprintf(stderr, "Error: infinite loop terminated\n");
 | 
			
		||||
  return 42;
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user