File:  [Research Unix] / researchv10no / cmd / odist / ape / eprintf.c
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Tue Apr 24 17:21:35 2018 UTC (8 years, 1 month ago) by root
Branches: belllabs, MAIN
CVS tags: researchv10, HEAD
researchv10 Norman

#include <stdarg.h>
#include <stdio.h>
#include <time.h>
#include <unistd.h>
#include "dist.h"

char *prog;

void
eprintf(char *fmt, ...)
{
	time_t now;
	char mesg[MAXLINE];
	va_list ap;
	static int fd = -1;

	time(&now);
	sprintf(mesg, "%s[%d %.24s]: ", prog, getpid(), ctime(&now));
	va_start(ap, fmt);
	vsprintf(mesg + strlen(mesg), fmt, ap);
	strcat(mesg, "\n");
	write(2, mesg, strlen(mesg));
	if (fd < 0)
		fd = open(SDIR "/log", 1);
	lseek(fd, 0L, 2);	/* we really want O_APPEND mode, but... */
	write(fd, mesg, strlen(mesg));
}

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.