All of lore.kernel.org
 help / color / mirror / Atom feed
From: Anthony Liguori <aliguori@us.ibm.com>
To: xen-devel@lists.xensource.com
Cc: Ewan Mellor <ewan@xensource.com>
Subject: Re: [Xen-changelog] Make xenstored reopen its trace file on SIGHUP. This allows one to rotate the
Date: Mon, 07 Nov 2005 11:15:34 -0600	[thread overview]
Message-ID: <436F8BB6.1090207@us.ibm.com> (raw)
In-Reply-To: <E1EZ6jH-0002pi-4u@xenbits.xensource.com>

Xen patchbot -unstable wrote:

> 
>+void reopen_log()
>+{
>+	if (!tracefile)
>+		return;
>+
>+	if (tracefd > 0)
>+		close(tracefd);
>+	tracefd = open(tracefile, O_WRONLY|O_CREAT|O_APPEND, 0600);
>+	if (tracefd < 0) {
>+		perror("Could not open tracefile");
>+		return;
>+	}
>+	write(tracefd, "\n***\n", strlen("\n***\n"));
>+}
>+
>  
>
perror and strlen are not safe to call from a signal handler.

I suggest just removing the perror call altogether and replacing strlen 
with sizeof() - 1.

Regards,

Anthony Liguori

> static bool write_messages(struct connection *conn)
> {
> 	int ret;
>@@ -1498,11 +1514,7 @@
> 			outputpid = true;
> 			break;
> 		case 'T':
>-			tracefd = open(optarg, O_WRONLY|O_CREAT|O_APPEND, 0600);
>-			if (tracefd < 0)
>-				barf_perror("Could not open tracefile %s",
>-					    optarg);
>-                        write(tracefd, "\n***\n", strlen("\n***\n"));
>+			tracefile = optarg;
> 			break;
> 		case 'V':
> 			verbose = true;
>@@ -1511,6 +1523,8 @@
> 	}
> 	if (optind != argc)
> 		barf("%s: No arguments desired", argv[0]);
>+
>+	reopen_log();
> 
> 	if (dofork) {
> 		openlog("xenstored", 0, LOG_DAEMON);
>@@ -1577,6 +1591,8 @@
> 		close(STDOUT_FILENO);
> 		close(STDERR_FILENO);
> 	}
>+
>+	signal(SIGHUP, reopen_log);
> 
> #ifdef TESTING
> 	signal(SIGUSR1, stop_failtest);
>
>_______________________________________________
>Xen-changelog mailing list
>Xen-changelog@lists.xensource.com
>http://lists.xensource.com/xen-changelog
>
>  
>

       reply	other threads:[~2005-11-07 17:15 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <E1EZ6jH-0002pi-4u@xenbits.xensource.com>
2005-11-07 17:15 ` Anthony Liguori [this message]
2005-11-07 17:23   ` [Xen-changelog] Make xenstored reopen its trace file on SIGHUP. This allows one to rotate the Ewan Mellor
2005-11-07 17:24   ` Hollis Blanchard
2005-11-07 17:36     ` Anthony Liguori

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=436F8BB6.1090207@us.ibm.com \
    --to=aliguori@us.ibm.com \
    --cc=ewan@xensource.com \
    --cc=xen-devel@lists.xensource.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.