static char *log_name_patt;
static int log_params;
static int log_filename_size;
-volatile int log_switch_nest;
+static int log_switch_nest;
static int
do_log_switch(struct tm *tm)
fd = sh_open(name, O_WRONLY | O_CREAT | O_APPEND, 0666);
if (fd < 0)
die("Unable to open log file %s: %m", name);
- close(2);
- dup(fd);
+ dup2(fd, 2);
close(fd);
- close(1);
- dup(2);
switched = 1;
}
log_switch_nest--;
}
void
-log_file(byte *name)
+log_file(const char *name)
{
if (name)
{
log_pid = getpid();
}
+void
+log_switch_disable(void)
+{
+ log_switch_nest++;
+}
+
+void
+log_switch_enable(void)
+{
+ ASSERT(log_switch_nest);
+ log_switch_nest--;
+}
+
#ifdef TEST
int main(int argc, char **argv)