git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Linus Torvalds <torvalds@osdl.org>
To: Jason Riedy <ejr@EECS.Berkeley.EDU>
Cc: git@vger.kernel.org
Subject: Re: Solaris cloning woes partly diagnosed
Date: Sun, 2 Apr 2006 13:28:27 -0700 (PDT)	[thread overview]
Message-ID: <Pine.LNX.4.64.0604021312510.3050@g5.osdl.org> (raw)
In-Reply-To: <824.1144007555@lotus.CS.Berkeley.EDU>



On Sun, 2 Apr 2006, Jason Riedy wrote:
> 
> Solaris folks will say you should be using sigaction with
> SA_RESTART.  IIRC, SA_RESTART isn't guaranteed to be there 
> or work, but all the systems I deal with right now have it.

I think we might as well do that _too_.

However, once you use "sigaction()", you don't need to re-arm the signal 
handler any more, so I'd suggest a simpler patch like this instead..

Junio, I think this confirms/explains the Solaris breakage.

I'll re-send the "anal stdio semantics" version of the patch on top of 
this in the next email.

			Linus
----
Subject: Fix Solaris stdio signal handling stupidities

This uses sigaction() to install the SIGALRM handler with SA_RESTART, so
that Solaris stdio doesn't break completely when a signal interrupts a
read.

Thanks to Jason Riedy for confirming the silly Solaris signal behaviour.

Signed-off-by: Linus Torvalds <torvalds@osdl.org>
----

diff --git a/pack-objects.c b/pack-objects.c
index ccfaa5f..1817b58 100644
--- a/pack-objects.c
+++ b/pack-objects.c
@@ -58,7 +58,7 @@ static int nr_objects = 0, nr_alloc = 0,
 static const char *base_name;
 static unsigned char pack_file_sha1[20];
 static int progress = 1;
-static volatile int progress_update = 0;
+static volatile sig_atomic_t progress_update = 0;
 
 /*
  * The object names in objects array are hashed with this hashtable,
@@ -879,7 +879,6 @@ static int try_delta(struct unpacked *cu
 
 static void progress_interval(int signum)
 {
-	signal(SIGALRM, progress_interval);
 	progress_update = 1;
 }
 
@@ -1025,6 +1024,23 @@ static int reuse_cached_pack(unsigned ch
 	return 1;
 }
 
+static void setup_progress_signal(void)
+{
+	struct sigaction sa;
+	struct itimerval v;
+
+	memset(&sa, 0, sizeof(sa));
+	sa.sa_handler = progress_interval;
+	sigemptyset(&sa.sa_mask);
+	sa.sa_flags = SA_RESTART;
+	sigaction(SIGALRM, &sa, NULL);
+
+	v.it_interval.tv_sec = 1;
+	v.it_interval.tv_usec = 0;
+	v.it_value = v.it_interval;
+	setitimer(ITIMER_REAL, &v, NULL);
+}
+
 int main(int argc, char **argv)
 {
 	SHA_CTX ctx;
@@ -1090,13 +1106,8 @@ int main(int argc, char **argv)
 	prepare_packed_git();
 
 	if (progress) {
-		struct itimerval v;
-		v.it_interval.tv_sec = 1;
-		v.it_interval.tv_usec = 0;
-		v.it_value = v.it_interval;
-		signal(SIGALRM, progress_interval);
-		setitimer(ITIMER_REAL, &v, NULL);
 		fprintf(stderr, "Generating pack...\n");
+		setup_progress_signal();
 	}
 
 	while (fgets(line, sizeof(line), stdin) != NULL) {

  reply	other threads:[~2006-04-02 20:28 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-04-02 10:41 Solaris cloning woes partly diagnosed Junio C Hamano
2006-04-02 18:33 ` Linus Torvalds
2006-04-02 19:10   ` Jason Riedy
2006-04-02 19:22     ` Linus Torvalds
2006-04-02 19:18   ` Linus Torvalds
2006-04-02 19:52     ` Jason Riedy
2006-04-02 20:28       ` Linus Torvalds [this message]
2006-04-02 20:31         ` [PATCH 2/2] pack-objects: be incredibly anal about stdio semantics Linus Torvalds
2006-04-02 21:09           ` Junio C Hamano
2006-04-02 21:21             ` Linus Torvalds
2006-04-02 22:12               ` Jason Riedy
2006-04-02 22:58                 ` Linus Torvalds
2006-04-02 22:29         ` [PATCH] Use sigaction and SA_RESTART in read-tree.c; add option in Makefile Jason Riedy
2006-04-03  1:02           ` Linus Torvalds
2006-04-03  4:20           ` Junio C Hamano
2006-04-03  4:40             ` Linus Torvalds
2006-04-03  3:06     ` Solaris cloning woes partly diagnosed Linus Torvalds
2006-04-04 18:21   ` H. Peter Anvin
2006-04-04  8:47 ` [RFH] Solaris cloning woes Junio C Hamano
2006-04-04 18:53   ` Jason Riedy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.LNX.4.64.0604021312510.3050@g5.osdl.org \
    --to=torvalds@osdl.org \
    --cc=ejr@EECS.Berkeley.EDU \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).