diff options
author | Zhang Qiang <qiang.z.zhang@intel.com> | 2012-05-29 12:22:00 +0800 |
---|---|---|
committer | Zhang Qiang <qiang.z.zhang@intel.com> | 2012-05-29 12:22:00 +0800 |
commit | 02f0634ac29e19c68279e5544cac963e7f1203b8 (patch) | |
tree | b983472f94ef063cedf866d8ecfb55939171779d /common/util_log.c | |
parent | e776056ea09ba0b6d9505ced6913c9190a12d632 (diff) | |
download | db4-02f0634ac29e19c68279e5544cac963e7f1203b8.tar.gz db4-02f0634ac29e19c68279e5544cac963e7f1203b8.tar.bz2 db4-02f0634ac29e19c68279e5544cac963e7f1203b8.zip |
Diffstat (limited to 'common/util_log.c')
-rw-r--r-- | common/util_log.c | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/common/util_log.c b/common/util_log.c new file mode 100644 index 0000000..cb2cfa4 --- /dev/null +++ b/common/util_log.c @@ -0,0 +1,45 @@ +/*- + * See the file LICENSE for redistribution information. + * + * Copyright (c) 2000-2009 Oracle. 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); +} |