Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 3dbe27e

Browse files
committed
cron_support.c pthread_mutex_t initializer added
1 parent 5c7512e commit 3dbe27e

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

‎cron_support.c‎

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#include "cron_support.h"
77

88
FILE *fp;
9-
pthread_mutex_t mutex; // 뮤텍스 객체 선언
9+
pthread_mutex_t mutex=PTHREAD_MUTEX_INITIALIZER; // 뮤텍스 객체 선언
1010
extern char reservation_command[BUFFER_SIZE][MAX_BUFFER_SIZE]; // 예약 명령 목록
1111

1212
/**
@@ -90,11 +90,10 @@ void write_log(int command_type, char *command) // 로그 파일에 이력 기
9090
struct tm *now_tm;
9191

9292
pthread_mutex_lock(&mutex);
93+
9394
if ((fp = fopen(CRONTAB_LOG, "r+")) == NULL)
94-
{
95-
fprintf(stderr, "write_log: fopen error for %s\n", CRONTAB_LOG);
96-
return;
97-
}
95+
fp = fopen(CRONTAB_LOG, "w");
96+
9897
fseek(fp, 0, SEEK_END);
9998

10099
time(&now_t);
@@ -114,8 +113,6 @@ void write_log(int command_type, char *command) // 로그 파일에 이력 기
114113
fprintf(fp, "[%.24s] %s %s\n", asctime(now_tm), "run", command);
115114
break;
116115
}
117-
//system(temp);
118-
//fflush(fp);
119116
fclose(fp);
120117
pthread_mutex_unlock(&mutex);
121118
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /