|
List Info
Thread: patch to create pid files
|
|
| patch to create pid files |

|
2006-05-16 23:22:45 |
Hello JACK developers,
Attached is a small patch that adds an option to jackd for
it to create a pid
file. If the option is given and no pidfile is specified, a
default of
"/var/run/jackd.pid" is used, otherwise the
requested pidfile is used. If
the new option (-i or --pid-file) is not given, jackd will
continue to behave
as before. The patch is against the current stable version
of jack (0.100.0),
as CVS accces is not responding (No route to host).
I also tried adding support for jackd to background and
daemonise itself, but
kept running into problems getting the following error, so I
am shelving that
for now.
cannot create inter-client FIFO
[/dev/shm/jack-610/default/jack-ack-fifo-24684-1] (No such
file or directory)
thanks,
donfede
--
Federico Grau
Free Software Developer and Sysadmin
Radio Free Asia
2025 M Street, NW
Suite 300
Washington, DC 20036
202-587-2046 Telephone
202-721-7468 Facsimile
CONFIDENTIAL COMMUNICATION
This e-mail message is intended only for the use of the
addressee and may
contain information that is privileged and confidential.
Any unauthorized
dissemination, distribution, or copying is strictly
prohibited. If you
receive this transmission in error, please contact
network rfa.org.
diff -Naur
jack-audio-connection-kit-0.100.0_ORG/configure.ac
jack-audio-connection-kit-0.100.0/configure.ac
---
jack-audio-connection-kit-0.100.0_ORG/configure.ac 2006-05-1
6 17:57:46.000000000 -0400
+++
jack-audio-connection-kit-0.100.0/configure.ac 2006-05-16
18:00:06.000000000 -0400
 -426,6
+426,21 
AC_SUBST(DEFAULT_TMP_DIR)
AC_DEFINE_UNQUOTED(DEFAULT_TMP_DIR,"$DEFAULT_TMP_DIR
",[Default tmp directory])
+
+# allow specifying default PID file
+AC_ARG_WITH(default-pidfile,
+ [ --with-default-pidfile=PATH where jackd
will write a pid file (/var/run/jackd.pid)])
+
+if test "x$with_default_pidfile" =
"x" ; then
+ DEFAULT_PID_FILE=/var/run/jackd.pid
+else
+ DEFAULT_PID_FILE=$with_default_pidfile
+fi
+
+AC_SUBST(DEFAULT_PID_FILE)
+AC_DEFINE_UNQUOTED(DEFAULT_PID_FILE,"$DEFAULT_PID_FIL
E",[Default PID file])
+
+
# Check for barrier functions in the pthreads library. The
default
# option setting may be OS-dependent, otherwise it's
"yes".
test "x$USE_BARRIER" = "x"
&& USE_BARRIER="yes"
diff -Naur
jack-audio-connection-kit-0.100.0_ORG/jackd/jackd.1.in
jack-audio-connection-kit-0.100.0/jackd/jackd.1.in
---
jack-audio-connection-kit-0.100.0_ORG/jackd/jackd.1.in 2006-
05-16 17:57:46.000000000 -0400
+++
jack-audio-connection-kit-0.100.0/jackd/jackd.1.in 2006-05-1
6 19:10:46.000000000 -0400
 -79,6
+79,10 
\fB\-\-silent\fR
Silence any output during operation.
.TP
+\fB\-i, \-\-pid-file\fR [\fI/path/to/pidfile\fR]
+Write the pid of the process to the specified file. If no
pid file
+is given then /var/run/jackd.pid is used as a default.
+.TP
\fB\-T, \-\-temporary\fR
Exit once all clients have closed their connections.
.TP
diff -Naur
jack-audio-connection-kit-0.100.0_ORG/jackd/jackd.c
jack-audio-connection-kit-0.100.0/jackd/jackd.c
---
jack-audio-connection-kit-0.100.0_ORG/jackd/jackd.c 2005-01-
15 20:56:45.000000000 -0500
+++
jack-audio-connection-kit-0.100.0/jackd/jackd.c 2006-05-16
19:12:35.000000000 -0400
 -61,6
+61,8 
static int do_mlock = 1;
static int temporary = 0;
static int verbose = 0;
+int pid_flag = 0;
+char *pid_file = NULL;
static int client_timeout = 500; /* msecs */
static unsigned int port_max = 128;
static int do_unlock = 0;
 -90,8
+92,20 
/* ensure that we are in our own process group so that
kill (SIG, -pgrp) does the right thing.
*/
+ setsid();
- setsid ();
+ /* create a pid file if requested */
+ if (pid_flag) {
+ pid_t pid = getpid();
+ FILE *pid_file_h;
+ pid_file_h=fopen(pid_file, "w");
+ if (!pid_file_h)
+ perror("cannot create pid file");
+ else {
+ fprintf(pid_file_h,"%d\n", pid);
+ fclose(pid_file_h);
+ }
+ }
pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
 -364,6
+378,7 
" [ --port-max OR -p
maximum-number-of-ports]\n"
" [ --verbose OR -v ]\n"
" [ --silent OR -s ]\n"
+" [ --pid-file OR -i
/path/to/pidfile]\n"
" [ --version OR -V ]\n"
" -d driver [ ... driver args ... ]\n"
" where driver can be `alsa',
`coreaudio', `dummy',\n"
 -414,6
+429,11 
* we know there is no other server actively using that
name.
*/
+ /* delete the pid file if used */
+ if (pid_flag) {
+ unlink(pid_file);
+ }
+
/* nothing to do if the server directory does not exist */
if ((dir = opendir (dir_name)) == NULL) {
return;
 -460,7
+480,7 
{
jack_driver_desc_t * desc;
- const char *options =
"-ad:P:uvshVRTFl:t:mn:p:";
+ const char *options =
"-ad:P:uvshVRTFl:t:mn:p:i::";
struct option long_options[] =
{
{ "driver", 1, 0, 'd' },
 -476,6
+496,7 
{ "temporary", 0, 0, 'T' },
{ "version", 0, 0, 'V' },
{ "silent", 0, 0, 's' },
+ { "pid-file", optional_argument, 0,
'i'},
{ 0, 0, 0, 0 }
};
int opt = 0;
 -583,6
+604,14 
show_version = 1;
break;
+ case 'i':
+ pid_flag = 1;
+ if (optarg)
+ pid_file = optarg;
+ else
+ pid_file = DEFAULT_PID_FILE;
+ break;
+
default:
fprintf (stderr, "unknown option character
%c\n",
optopt);
|
|
| patch to create pid files |

|
2006-05-17 16:04:00 |
On Tue, May 16, 2006 at 07:22:45PM -0400, Federico Grau
wrote:
> Hello JACK developers,
>
> Attached is a small patch that adds an option to jackd
for it to create a pid
> file. If the option is given and no pidfile is
specified, a default of
> "/var/run/jackd.pid" is used, otherwise the
requested pidfile is used. If
> the new option (-i or --pid-file) is not given, jackd
will continue to behave
> as before. The patch is against the current stable
version of jack (0.100.0),
> as CVS accces is not responding (No route to host).
>
> I also tried adding support for jackd to background and
daemonise itself, but
> kept running into problems getting the following error,
so I am shelving that
> for now.
>
> cannot create inter-client FIFO
[/dev/shm/jack-610/default/jack-ack-fifo-24684-1] (No such
file or directory)
>
> thanks,
> donfede
>
Attached is the same patch against the jackit CVS
repository.
donfede
--
Federico Grau
Free Software Developer and Sysadmin
Radio Free Asia
2025 M Street, NW
Suite 300
Washington, DC 20036
202-587-2046 Telephone
202-721-7468 Facsimile
CONFIDENTIAL COMMUNICATION
This e-mail message is intended only for the use of the
addressee and may
contain information that is privileged and confidential.
Any unauthorized
dissemination, distribution, or copying is strictly
prohibited. If you
receive this transmission in error, please contact
network rfa.org.
Index: configure.ac
============================================================
=======
RCS file: /cvsroot/jackit/jack/configure.ac,v
retrieving revision 1.84
diff -u -r1.84 configure.ac
--- configure.ac 16 May 2006 16:32:07 -0000 1.84
+++ configure.ac 17 May 2006 16:01:27 -0000
 -521,6
+521,21 
AC_SUBST(DEFAULT_TMP_DIR)
AC_DEFINE_UNQUOTED(DEFAULT_TMP_DIR,"$DEFAULT_TMP_DIR
",[Default tmp directory])
+
+# allow specifying default PID file
+AC_ARG_WITH(default-pidfile,
+ [ --with-default-pidfile=PATH where jackd
will write a pid file (/var/run/jackd.pid)])
+
+if test "x$with_default_pidfile" =
"x" ; then
+ DEFAULT_PID_FILE=/var/run/jackd.pid
+else
+ DEFAULT_PID_FILE=$with_default_pidfile
+fi
+
+AC_SUBST(DEFAULT_PID_FILE)
+AC_DEFINE_UNQUOTED(DEFAULT_PID_FILE,"$DEFAULT_PID_FIL
E",[Default PID file])
+
+
# Check for barrier functions in the pthreads library. The
default
# option setting may be OS-dependent, otherwise it's
"yes".
test "x$USE_BARRIER" = "x"
&& USE_BARRIER="yes"
Index: jackd/jackd.1.in
============================================================
=======
RCS file: /cvsroot/jackit/jack/jackd/jackd.1.in,v
retrieving revision 1.24
diff -u -r1.24 jackd.1.in
--- jackd/jackd.1.in 15 May 2006 17:12:44 -0000 1.24
+++ jackd/jackd.1.in 17 May 2006 16:01:27 -0000
 -81,6
+81,10 
\fB\-\-silent\fR
Silence any output during operation.
.TP
+\fB\-i, \-\-pid-file\fR [\fI/path/to/pidfile\fR]
+Write the pid of the process to the specified file. If no
pid file
+is given then /var/run/jackd.pid is used as a default.
+.TP
\fB\-T, \-\-temporary\fR
Exit once all clients have closed their connections.
.TP
Index: jackd/jackd.c
============================================================
=======
RCS file: /cvsroot/jackit/jack/jackd/jackd.c,v
retrieving revision 1.57
diff -u -r1.57 jackd.c
--- jackd/jackd.c 15 May 2006 17:12:44 -0000 1.57
+++ jackd/jackd.c 17 May 2006 16:01:27 -0000
 -62,6
+62,8 
static int do_mlock = 1;
static int temporary = 0;
static int verbose = 0;
+static int pid_flag = 0;
+static char *pid_file = NULL;
static int client_timeout = 0; /* msecs; if zero, use
period size. */
static unsigned int port_max = 128;
static int do_unlock = 0;
 -97,6
+99,19 
pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
+ /* create a pid file if requested */
+ if (pid_flag) {
+ pid_t pid = getpid();
+ FILE *pid_file_h;
+ pid_file_h=fopen(pid_file, "w");
+ if (!pid_file_h)
+ fprintf (stderr, "cannot create pid file
%s\n", pid_file);
+ else {
+ fprintf(pid_file_h,"%d\n", pid);
+ fclose(pid_file_h);
+ }
+ }
+
/* what's this for?
POSIX says that signals are delivered like this:
 -369,6
+384,7 
" [ --port-max OR -p
maximum-number-of-ports]\n"
" [ --debug-timer OR -D ]\n"
" [ --verbose OR -v ]\n"
+" [ --pid-file OR -i
/path/to/pidfile]\n"
" [ --clocksource OR -c [ c(ycle) |
h(pet) | s(ystem) ]\n"
" [ --silent OR -s ]\n"
" [ --version OR -V ]\n"
 -422,6
+438,11 
* we know there is no other server actively using that
name.
*/
+ /* delete the pid file if used */
+ if (pid_flag) {
+ unlink(pid_file);
+ }
+
/* nothing to do if the server directory does not exist */
if ((dir = opendir (dir_name)) == NULL) {
return;
 -507,7
+528,7 
{
jack_driver_desc_t * desc;
- const char *options =
"-ad:P:uvshVRTFl:t:mn:p:c:";
+ const char *options =
"-ad:P:uvshVRTFl:t:mn:p:i::c:";
struct option long_options[] =
{
{ "driver", 1, 0, 'd' },
 -523,6
+544,7 
{ "temporary", 0, 0, 'T' },
{ "version", 0, 0, 'V' },
{ "silent", 0, 0, 's' },
+ { "pid-file", optional_argument, 0,
'i'},
{ "clock-source", 1, 0, 'c' },
{ 0, 0, 0, 0 }
};
 -569,6
+591,14 
frame_time_offset = JACK_MAX_FRAMES - atoi(optarg);
break;
+ case 'i':
+ pid_flag = 1;
+ if (optarg)
+ pid_file = optarg;
+ else
+ pid_file = DEFAULT_PID_FILE;
+ break;
+
case 'm':
do_mlock = 0;
break;
|
|
[1-2]
|
|