summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorAlexandre Ratchov <ratchov@cvs.openbsd.org>2009-10-05 07:05:25 +0000
committerAlexandre Ratchov <ratchov@cvs.openbsd.org>2009-10-05 07:05:25 +0000
commit3dc1de0fadffb0117f49dc36fd559c9051df5ec5 (patch)
tree303dd668ce8f1043e4d53072656b68ddc8aa8c5b /usr.bin
parentc8b9060fa761eb633683dc1518cc006cab8c088d (diff)
add -d flag. When started in server mode, if the -d flag is
used aucat and midicat don't daemonize and log on stderr.
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/aucat/aucat.112
-rw-r--r--usr.bin/aucat/aucat.c26
-rw-r--r--usr.bin/aucat/midicat.112
-rw-r--r--usr.bin/aucat/sock.c3
4 files changed, 37 insertions, 16 deletions
diff --git a/usr.bin/aucat/aucat.1 b/usr.bin/aucat/aucat.1
index 0ed8dcf21f9..053f3150d92 100644
--- a/usr.bin/aucat/aucat.1
+++ b/usr.bin/aucat/aucat.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: aucat.1,v 1.58 2009/09/27 11:51:20 ratchov Exp $
+.\" $OpenBSD: aucat.1,v 1.59 2009/10/05 07:05:24 ratchov Exp $
.\"
.\" Copyright (c) 2006 Alexandre Ratchov <alex@caoua.org>
.\"
@@ -14,7 +14,7 @@
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: September 27 2009 $
+.Dd $Mdocdate: October 5 2009 $
.Dt AUCAT 1
.Os
.Sh NAME
@@ -23,7 +23,7 @@
.Sh SYNOPSIS
.Nm aucat
.Bk -words
-.Op Fl lnu
+.Op Fl dlnu
.Op Fl b Ar nframes
.Op Fl C Ar min : Ns Ar max
.Op Fl c Ar min : Ns Ar max
@@ -65,6 +65,12 @@ and thus controls the playback latency.
.Xc
The range of channel numbers on the record or playback stream, respectively.
The default is 0:1, i.e. stereo.
+.It Fl d
+Do not daemonize.
+If this option is specified,
+.Nm
+will run in the foreground and log to
+.Em stderr .
.It Fl e Ar enc
Encoding of the playback or recording stream (see below).
The default is signed, 16-bit, native byte order.
diff --git a/usr.bin/aucat/aucat.c b/usr.bin/aucat/aucat.c
index 174de5f18b6..dc4145923bd 100644
--- a/usr.bin/aucat/aucat.c
+++ b/usr.bin/aucat/aucat.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: aucat.c,v 1.68 2009/09/27 11:51:20 ratchov Exp $ */
+/* $OpenBSD: aucat.c,v 1.69 2009/10/05 07:05:24 ratchov Exp $ */
/*
* Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org>
*
@@ -344,7 +344,7 @@ getbasepath(char *base, size_t size)
void
aucat_usage(void)
{
- (void)fputs("usage: " PROG_AUCAT " [-lnu] [-b nframes] "
+ (void)fputs("usage: " PROG_AUCAT " [-dlnu] [-b nframes] "
"[-C min:max] [-c min:max] [-e enc] [-f device]\n"
"\t[-h fmt] [-i file] [-m mode] [-o file] [-r rate] [-s name]\n"
"\t[-U unit] [-v volume] [-x policy]\n",
@@ -354,7 +354,7 @@ aucat_usage(void)
int
aucat_main(int argc, char **argv)
{
- int c, u_flag, l_flag, n_flag, hdr, xrun, suspend = 0, unit;
+ int c, u_flag, d_flag, l_flag, n_flag, hdr, xrun, suspend = 0, unit;
struct farg *fa;
struct farglist ifiles, ofiles, sfiles;
struct aparams ipar, opar, dipar, dopar;
@@ -366,6 +366,7 @@ aucat_main(int argc, char **argv)
aparams_init(&ipar, 0, 1, 44100);
aparams_init(&opar, 0, 1, 44100);
u_flag = 0;
+ d_flag = 0;
l_flag = 0;
n_flag = 0;
unit = -1;
@@ -379,8 +380,11 @@ aucat_main(int argc, char **argv)
bufsz = 44100 * 4 / 15; /* XXX: use milliseconds, not frames */
mode = 0;
- while ((c = getopt(argc, argv, "nb:c:C:e:r:h:x:v:i:o:f:m:lus:U:")) != -1) {
+ while ((c = getopt(argc, argv, "dnb:c:C:e:r:h:x:v:i:o:f:m:lus:U:")) != -1) {
switch (c) {
+ case 'd':
+ d_flag = 1;
+ break;
case 'n':
n_flag = 1;
break;
@@ -575,7 +579,7 @@ aucat_main(int argc, char **argv)
snprintf(path, sizeof(path), "%s/%s%u", base,
DEFAULT_SOFTAUDIO, unit);
listen_new(&listen_ops, path);
- if (daemon(0, 0) < 0)
+ if (!d_flag && daemon(0, 0) < 0)
err(1, "daemon");
}
@@ -632,14 +636,14 @@ aucat_main(int argc, char **argv)
void
midicat_usage(void)
{
- (void)fputs("usage: " PROG_MIDICAT " [-l] [-f device] "
+ (void)fputs("usage: " PROG_MIDICAT " [-dl] [-f device] "
"[-i file] [-o file] [-U unit]\n",
stderr);
}
int
midicat_main(int argc, char **argv)
{
- int c, l_flag, unit, fd;
+ int c, d_flag, l_flag, unit, fd;
struct farglist dfiles, ifiles, ofiles;
char base[PATH_MAX], path[PATH_MAX];
struct farg *fa;
@@ -647,14 +651,18 @@ midicat_main(int argc, char **argv)
struct aproc *p;
struct abuf *buf;
+ d_flag = 0;
l_flag = 0;
unit = -1;
SLIST_INIT(&dfiles);
SLIST_INIT(&ifiles);
SLIST_INIT(&ofiles);
- while ((c = getopt(argc, argv, "i:o:lf:U:")) != -1) {
+ while ((c = getopt(argc, argv, "di:o:lf:U:")) != -1) {
switch (c) {
+ case 'd':
+ d_flag = 1;
+ break;
case 'i':
farg_add(&ifiles, &aparams_none, &aparams_none,
0, HDR_RAW, 0, optarg);
@@ -719,7 +727,7 @@ midicat_main(int argc, char **argv)
snprintf(path, sizeof(path), "%s/%s%u", base,
DEFAULT_MIDITHRU, unit);
listen_new(&listen_ops, path);
- if (daemon(0, 0) < 0)
+ if (!d_flag && daemon(0, 0) < 0)
err(1, "daemon");
}
while (!SLIST_EMPTY(&ifiles)) {
diff --git a/usr.bin/aucat/midicat.1 b/usr.bin/aucat/midicat.1
index a86889de616..442f19ce64b 100644
--- a/usr.bin/aucat/midicat.1
+++ b/usr.bin/aucat/midicat.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: midicat.1,v 1.3 2009/09/27 11:51:20 ratchov Exp $
+.\" $OpenBSD: midicat.1,v 1.4 2009/10/05 07:05:24 ratchov Exp $
.\"
.\" Copyright (c) 2006 Alexandre Ratchov <alex@caoua.org>
.\"
@@ -14,7 +14,7 @@
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: September 27 2009 $
+.Dd $Mdocdate: October 5 2009 $
.Dt MIDICAT 1
.Os
.Sh NAME
@@ -22,7 +22,7 @@
.Nd MIDI server and manipulation tool
.Sh SYNOPSIS
.Nm midicat
-.Op Fl l
+.Op Fl dl
.Op Fl f Ar device
.Op Fl i Ar file
.Op Fl o Ar file
@@ -46,6 +46,12 @@ device or
.Nm
socket to use for MIDI input/output.
In server mode, devices are subscribed to the MIDI thru box.
+.It Fl d
+Do not daemonize.
+If this option is specified,
+.Nm
+will run in the foreground and log to
+.Em stderr .
.It Fl i Ar file
Send contents of this file to the device.
If the option argument is
diff --git a/usr.bin/aucat/sock.c b/usr.bin/aucat/sock.c
index 1f4a6fcf6b9..d293cc1982f 100644
--- a/usr.bin/aucat/sock.c
+++ b/usr.bin/aucat/sock.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sock.c,v 1.29 2009/09/27 11:51:20 ratchov Exp $ */
+/* $OpenBSD: sock.c,v 1.30 2009/10/05 07:05:24 ratchov Exp $ */
/*
* Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org>
*
@@ -52,6 +52,7 @@ struct fileops sock_ops = {
pipe_revents
};
+
void
rsock_done(struct aproc *p)
{