]> git.feebdaed.xyz Git - linuxyz.git/commitdiff
fault sig done
authorseantywork <seantywork@gmail.com>
Sun, 10 Aug 2025 23:57:53 +0000 (08:57 +0900)
committerseantywork <seantywork@gmail.com>
Sun, 10 Aug 2025 23:57:53 +0000 (08:57 +0900)
fault-signal/main.c

index b62f752d700e56e4812d5e89565b17da1b6c55f0..54f5c5273bedb7f04da7b4cd4c8100e6ee0ea5ae 100644 (file)
@@ -7,12 +7,12 @@
 
 void ch_handler(int sig){
     struct tm tm_info;
-    char timebuf[128] = {0};
+    char timebuf[32] = {0};
     time_t ch_timer = time(NULL);
     printf("sig received %d\n", sig);
        localtime_r(&ch_timer, &tm_info);
        strftime(timebuf, 128, "%Y-%m-%d %H:%M:%S", &tm_info);
-       printf("[%s] signal handled: %d\n", timebuf);
+       printf("[%s][SIG] signal handled\n", timebuf);
 }
 
 
@@ -20,18 +20,17 @@ int main(int argc, char** argv){
 
        time_t timer;
        struct tm tm_info;
-    pthread_t tid;
     int counter = 0;
-       char timebuf[128] = {0};
-
-       signal(SIGINT, ch_handler);
+       char timebuf[32] = {0};
+    
+    signal(SIGINT, ch_handler);
        while(counter < 100000000){
         timer = time(NULL);
                localtime_r(&timer, &tm_info);
         strftime(timebuf, 128, "%Y-%m-%d %H:%M:%S", &tm_info);
         counter += 1;
         if(counter % 100 == 0){
-            printf("[%s] counting: %d\n", timebuf, counter);
+            printf("[%s][CNT] counting: %d\n", timebuf, counter);
         }
        }