mariadb/storage/bdb/common/util_log.c

64 lines
1 KiB
C
Raw Normal View History

2001-03-04 19:42:05 -05:00
/*-
* See the file LICENSE for redistribution information.
*
2005-12-05 10:27:46 -08:00
* Copyright (c) 2000-2005
2001-03-04 19:42:05 -05:00
* Sleepycat Software. All rights reserved.
2005-07-20 15:48:22 -07:00
*
2005-12-05 10:27:46 -08:00
* $Id: util_log.c,v 12.4 2005/10/12 17:47:17 bostic Exp $
2001-03-04 19:42:05 -05:00
*/
#include "db_config.h"
#ifndef NO_SYSTEM_INCLUDES
#include <sys/types.h>
#include <stdlib.h>
#if TIME_WITH_SYS_TIME
#include <sys/time.h>
#include <time.h>
#else
#if HAVE_SYS_TIME_H
#include <sys/time.h>
#else
#include <time.h>
#endif
#endif
#include <string.h>
#endif
#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;
{
2005-12-05 10:27:46 -08:00
pid_t pid;
db_threadid_t tid;
2001-03-04 19:42:05 -05:00
FILE *fp;
time_t now;
if ((fp = fopen(fname, "w")) == NULL)
goto err;
(void)time(&now);
2005-12-05 10:27:46 -08:00
__os_id(NULL, &pid, &tid);
fprintf(fp, "%s: %lu %s", progname, (u_long)pid, ctime(&now));
2001-03-04 19:42:05 -05:00
if (fclose(fp) == EOF)
goto err;
return (0);
err: fprintf(stderr, "%s: %s: %s\n", progname, fname, strerror(errno));
return (1);
}