Use sigaction and SA_RESTART in read-tree.c; add option in Makefile.
Might as well ape the sigaction change in read-tree.c to avoid the same potential problems. The fprintf status output will be overwritten in a second, so don't bother guarding it. Do move the fputc after disabling SIGALRM to ensure we go to the next line, though. Also add a NO_SA_RESTART option in the Makefile in case someone doesn't have SA_RESTART but does restart (maybe older HP/UX?). We want the builder to chose this specifically in case the system both lacks SA_RESTART and does not restart stdio calls; a compat #define in git-compat-utils.h would silently allow broken systems. Signed-off-by: Jason Riedy <ejr@cs.berkeley.edu> Signed-off-by: Junio C Hamano <junkio@cox.net>
Jason Riedy committed
Apr 2, 2006 at 15:29 UTC
72fdfb50f721460e4cdff16fbe9c72d4ce6c668c
1 file changed
+19
-9
read-tree.c
+19
-9
@@ -273,10 +273,26 @@ static void unlink_entry(char *name)
273
274
static void progress_interval(int signum)
275
{
276
- signal(SIGALRM, progress_interval);
276
progress_update = 1;
277
}
278
279
+static void setup_progress_signal(void)
280
+{
281
+ struct sigaction sa;
282
+ struct itimerval v;
283
+
284
+ memset(&sa, 0, sizeof(sa));
285
+ sa.sa_handler = progress_interval;
286
+ sigemptyset(&sa.sa_mask);
287
+ sa.sa_flags = SA_RESTART;
288
+ sigaction(SIGALRM, &sa, NULL);
289
+
290
+ v.it_interval.tv_sec = 1;
291
+ v.it_interval.tv_usec = 0;
292
+ v.it_value = v.it_interval;
293
+ setitimer(ITIMER_REAL, &v, NULL);
294
+}
295
+
296
static void check_updates(struct cache_entry **src, int nr)
297
{
298
static struct checkout state = {
@@ -289,8 +305,6 @@ static void check_updates(struct cache_entry **src, int nr)
305
unsigned last_percent = 200, cnt = 0, total = 0;
306
307
if (update && verbose_update) {
292
- struct itimerval v;
293
-
308
for (total = cnt = 0; cnt < nr; cnt++) {
309
struct cache_entry *ce = src[cnt];
310
if (!ce->ce_mode || ce->ce_flags & mask)
@@ -302,12 +316,8 @@ static void check_updates(struct cache_entry **src, int nr)
316
total = 0;
317
318
if (total) {
305
- v.it_interval.tv_sec = 1;
306
- v.it_interval.tv_usec = 0;
307
- v.it_value = v.it_interval;
308
- signal(SIGALRM, progress_interval);
309
- setitimer(ITIMER_REAL, &v, NULL);
319
fprintf(stderr, "Checking files out...\n");
320
+ setup_progress_signal();
321
progress_update = 1;
322
}
323
cnt = 0;
@@ -341,8 +351,8 @@ static void check_updates(struct cache_entry **src, int nr)
351
}
352
}
353
if (total) {
344
- fputc('\n', stderr);
354
signal(SIGALRM, SIG_IGN);
355
+ fputc('\n', stderr);
356
}
357
}
358