From owner-freebsd-hackers Fri Sep 1 15:29:55 2000 Delivered-To: freebsd-hackers@freebsd.org Received: from Awfulhak.org (tun.AwfulHak.org [194.242.139.173]) by hub.freebsd.org (Postfix) with ESMTP id F35C637B424 for ; Fri, 1 Sep 2000 15:29:51 -0700 (PDT) Received: from hak.lan.Awfulhak.org (root@hak.lan.awfulhak.org [172.16.0.12]) by Awfulhak.org (8.9.3/8.9.3) with ESMTP id XAA70393; Fri, 1 Sep 2000 23:26:58 +0100 (BST) (envelope-from brian@hak.lan.Awfulhak.org) Received: from hak.lan.Awfulhak.org (brian@localhost [127.0.0.1]) by hak.lan.Awfulhak.org (8.11.0/8.11.0) with ESMTP id e81MQY716346; Fri, 1 Sep 2000 23:26:35 +0100 (BST) (envelope-from brian@hak.lan.Awfulhak.org) Message-Id: <200009012226.e81MQY716346@hak.lan.Awfulhak.org> X-Mailer: exmh version 2.1.1 10/15/1999 To: Alexander Maret Cc: "'freebsd-hackers@freebsd.org'" , brian@Awfulhak.org Subject: Re: Redirect stdout/stderr to syslog [OFF-TOPIC] In-Reply-To: Message from Alexander Maret of "Fri, 01 Sep 2000 13:58:56 +0200." <58A002A02C5ED311812E0050044517F00D25DA@erlangen01.atrada.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Fri, 01 Sep 2000 23:26:33 +0100 From: Brian Somers Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG > Hi, > > I wonder if it is possible to redirect stdout/stderr to syslog. > > Background: > I'm writing a program which starts (fork=>execvp) and observes > another program. I would like to redirect all output of the "execvped" > program to syslog. > > I know this is not really FBSD related but I hope you can help > me anyway. Please don't tell me that I should redirect the output > to a file and not to syslog. I know how to redirect the output to > a file (that's my prog doing at present state). I guess you could do something like: int fd; fd = open(_PATH_DEVNULL, O_RDONLY); dup2(fd, STDIN_FILENO); close(STDOUT_FILENO); openlog(....); dup2(STDOUT_FILENO, STDERR_FILENO); > Bye, > Alex -- Brian Don't _EVER_ lose your sense of humour ! To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message