summaryrefslogtreecommitdiff
path: root/src/common/util_log.c
blob: d158d3f088fcf3bfe3634524b0cb586de729a8d2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/*-
 * See the file LICENSE for redistribution information.
 *
 * Copyright (c) 2000, 2012 Oracle and/or its affiliates.  All rights reserved.
 *
 * $Id$
 */

#include "db_config.h"

#include "db_int.h"

/*
 * __db_util_logset --
 *	Log that we're running.
 *
 * PUBLIC: int __db_util_logset __P((const char *, char *));
 */
int
__db_util_logset(progname, fname)
	const char *progname;
	char *fname;
{
	pid_t pid;
	FILE *fp;
	time_t now;
	char time_buf[CTIME_BUFLEN];

	if ((fp = fopen(fname, "w")) == NULL)
		goto err;

	(void)time(&now);

	__os_id(NULL, &pid, NULL);
	fprintf(fp,
	    "%s: %lu %s", progname, (u_long)pid, __os_ctime(&now, time_buf));

	if (fclose(fp) == EOF)
		goto err;

	return (0);

err:	fprintf(stderr, "%s: %s: %s\n", progname, fname, strerror(errno));
	return (1);
}