jack1 codebase
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

782 lines
19KB

  1. /* -*- mode: c; c-file-style: "bsd"; -*- */
  2. /*
  3. Copyright (C) 2001-2005 Paul Davis
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  15. */
  16. #include <config.h>
  17. #include <stdio.h>
  18. #include <ctype.h>
  19. #include <signal.h>
  20. #include <getopt.h>
  21. #include <sys/types.h>
  22. #include <sys/shm.h>
  23. #include <sys/wait.h>
  24. #include <string.h>
  25. #include <errno.h>
  26. #include <stdlib.h>
  27. #include <dirent.h>
  28. #include <dlfcn.h>
  29. #include <jack/engine.h>
  30. #include <jack/internal.h>
  31. #include <jack/driver.h>
  32. #include <jack/shm.h>
  33. #include <jack/driver_parse.h>
  34. #include <jack/messagebuffer.h>
  35. #include <jack/midiport.h>
  36. #ifdef USE_CAPABILITIES
  37. #include <sys/stat.h>
  38. /* capgetp and capsetp are linux only extensions, not posix */
  39. #undef _POSIX_SOURCE
  40. #include <sys/capability.h>
  41. #include <jack/start.h>
  42. static struct stat pipe_stat;
  43. #endif /* USE_CAPABILITIES */
  44. static JSList *drivers = NULL;
  45. static sigset_t signals;
  46. static jack_engine_t *engine = NULL;
  47. static char *server_name = NULL;
  48. static int realtime = 1;
  49. static int realtime_priority = 10;
  50. static int do_mlock = 1;
  51. static int temporary = 0;
  52. static int verbose = 0;
  53. static int client_timeout = 0; /* msecs; if zero, use period size. */
  54. static unsigned int port_max = 256;
  55. static int do_unlock = 0;
  56. static jack_nframes_t frame_time_offset = 0;
  57. static int nozombies = 0;
  58. extern int sanitycheck (int, int);
  59. static void
  60. do_nothing_handler (int sig)
  61. {
  62. /* this is used by the child (active) process, but it never
  63. gets called unless we are already shutting down after
  64. another signal.
  65. */
  66. char buf[64];
  67. snprintf (buf, sizeof(buf),
  68. "received signal %d during shutdown (ignored)\n", sig);
  69. write (1, buf, strlen (buf));
  70. }
  71. static int
  72. jack_main (jack_driver_desc_t * driver_desc, JSList * driver_params)
  73. {
  74. int sig;
  75. int i;
  76. sigset_t allsignals;
  77. struct sigaction action;
  78. int waiting;
  79. /* ensure that we are in our own process group so that
  80. kill (SIG, -pgrp) does the right thing.
  81. */
  82. setsid ();
  83. pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
  84. /* what's this for?
  85. POSIX says that signals are delivered like this:
  86. * if a thread has blocked that signal, it is not
  87. a candidate to receive the signal.
  88. * of all threads not blocking the signal, pick
  89. one at random, and deliver the signal.
  90. this means that a simple-minded multi-threaded program can
  91. expect to get POSIX signals delivered randomly to any one
  92. of its threads,
  93. here, we block all signals that we think we might receive
  94. and want to catch. all "child" threads will inherit this
  95. setting. if we create a thread that calls sigwait() on the
  96. same set of signals, implicitly unblocking all those
  97. signals. any of those signals that are delivered to the
  98. process will be delivered to that thread, and that thread
  99. alone. this makes cleanup for a signal-driven exit much
  100. easier, since we know which thread is doing it and more
  101. importantly, we are free to call async-unsafe functions,
  102. because the code is executing in normal thread context
  103. after a return from sigwait().
  104. */
  105. sigemptyset (&signals);
  106. sigaddset(&signals, SIGHUP);
  107. sigaddset(&signals, SIGINT);
  108. sigaddset(&signals, SIGQUIT);
  109. sigaddset(&signals, SIGPIPE);
  110. sigaddset(&signals, SIGTERM);
  111. sigaddset(&signals, SIGUSR1);
  112. sigaddset(&signals, SIGUSR2);
  113. /* all child threads will inherit this mask unless they
  114. * explicitly reset it
  115. */
  116. pthread_sigmask (SIG_BLOCK, &signals, 0);
  117. if (!realtime && client_timeout == 0)
  118. client_timeout = 500; /* 0.5 sec; usable when non realtime. */
  119. /* get the engine/driver started */
  120. if ((engine = jack_engine_new (realtime, realtime_priority,
  121. do_mlock, do_unlock, server_name,
  122. temporary, verbose, client_timeout,
  123. port_max, getpid(), frame_time_offset,
  124. nozombies, drivers)) == 0) {
  125. jack_error ("cannot create engine");
  126. return -1;
  127. }
  128. jack_info ("loading driver ..");
  129. if (jack_engine_load_driver (engine, driver_desc, driver_params)) {
  130. jack_error ("cannot load driver module %s",
  131. driver_desc->name);
  132. goto error;
  133. }
  134. if (engine->driver->start (engine->driver) != 0) {
  135. jack_error ("cannot start driver");
  136. goto error;
  137. }
  138. /* install a do-nothing handler because otherwise pthreads
  139. behaviour is undefined when we enter sigwait.
  140. */
  141. sigfillset (&allsignals);
  142. action.sa_handler = do_nothing_handler;
  143. action.sa_mask = allsignals;
  144. action.sa_flags = SA_RESTART|SA_RESETHAND;
  145. for (i = 1; i < NSIG; i++) {
  146. if (sigismember (&signals, i)) {
  147. sigaction (i, &action, 0);
  148. }
  149. }
  150. if (verbose) {
  151. jack_info ("%d waiting for signals", getpid());
  152. }
  153. waiting = TRUE;
  154. while (waiting) {
  155. sigwait (&signals, &sig);
  156. jack_info ("jack main caught signal %d", sig);
  157. switch (sig) {
  158. case SIGUSR1:
  159. jack_dump_configuration(engine, 1);
  160. break;
  161. case SIGUSR2:
  162. /* driver exit */
  163. waiting = FALSE;
  164. break;
  165. default:
  166. waiting = FALSE;
  167. break;
  168. }
  169. }
  170. if (sig != SIGSEGV) {
  171. /* unblock signals so we can see them during shutdown.
  172. this will help prod developers not to lose sight of
  173. bugs that cause segfaults etc. during shutdown.
  174. */
  175. sigprocmask (SIG_UNBLOCK, &signals, 0);
  176. }
  177. jack_engine_delete (engine);
  178. return 1;
  179. error:
  180. jack_engine_delete (engine);
  181. return -1;
  182. }
  183. static jack_driver_desc_t *
  184. jack_drivers_get_descriptor (JSList * drivers, const char * sofile)
  185. {
  186. jack_driver_desc_t * descriptor, * other_descriptor;
  187. JackDriverDescFunction so_get_descriptor;
  188. JSList * node;
  189. void * dlhandle;
  190. char * filename;
  191. const char * dlerr;
  192. int err;
  193. char* driver_dir;
  194. if ((driver_dir = getenv("JACK_DRIVER_DIR")) == 0) {
  195. driver_dir = ADDON_DIR;
  196. }
  197. filename = malloc (strlen (driver_dir) + 1 + strlen (sofile) + 1);
  198. sprintf (filename, "%s/%s", driver_dir, sofile);
  199. if (verbose) {
  200. jack_info ("getting driver descriptor from %s", filename);
  201. }
  202. if ((dlhandle = dlopen (filename, RTLD_NOW|RTLD_GLOBAL)) == NULL) {
  203. jack_error ("could not open driver .so '%s': %s\n", filename, dlerror ());
  204. free (filename);
  205. return NULL;
  206. }
  207. so_get_descriptor = (JackDriverDescFunction)
  208. dlsym (dlhandle, "driver_get_descriptor");
  209. if ((dlerr = dlerror ()) != NULL) {
  210. jack_error("%s", dlerr);
  211. dlclose (dlhandle);
  212. free (filename);
  213. return NULL;
  214. }
  215. if ((descriptor = so_get_descriptor ()) == NULL) {
  216. jack_error ("driver from '%s' returned NULL descriptor\n", filename);
  217. dlclose (dlhandle);
  218. free (filename);
  219. return NULL;
  220. }
  221. if ((err = dlclose (dlhandle)) != 0) {
  222. jack_error ("error closing driver .so '%s': %s\n", filename, dlerror ());
  223. }
  224. /* check it doesn't exist already */
  225. for (node = drivers; node; node = jack_slist_next (node)) {
  226. other_descriptor = (jack_driver_desc_t *) node->data;
  227. if (strcmp (descriptor->name, other_descriptor->name) == 0) {
  228. jack_error ("the drivers in '%s' and '%s' both have the name '%s'; using the first\n",
  229. other_descriptor->file, filename, other_descriptor->name);
  230. /* FIXME: delete the descriptor */
  231. free (filename);
  232. return NULL;
  233. }
  234. }
  235. snprintf (descriptor->file, sizeof(descriptor->file), "%s", filename);
  236. free (filename);
  237. return descriptor;
  238. }
  239. static JSList *
  240. jack_drivers_load ()
  241. {
  242. struct dirent * dir_entry;
  243. DIR * dir_stream;
  244. const char * ptr;
  245. int err;
  246. JSList * driver_list = NULL;
  247. jack_driver_desc_t * desc;
  248. char* driver_dir;
  249. if ((driver_dir = getenv("JACK_DRIVER_DIR")) == 0) {
  250. driver_dir = ADDON_DIR;
  251. }
  252. /* search through the driver_dir and add get descriptors
  253. from the .so files in it */
  254. dir_stream = opendir (driver_dir);
  255. if (!dir_stream) {
  256. jack_error ("could not open driver directory %s: %s\n",
  257. driver_dir, strerror (errno));
  258. return NULL;
  259. }
  260. while ( (dir_entry = readdir (dir_stream)) ) {
  261. /* check the filename is of the right format */
  262. if (strncmp ("jack_", dir_entry->d_name, 5) != 0) {
  263. continue;
  264. }
  265. ptr = strrchr (dir_entry->d_name, '.');
  266. if (!ptr) {
  267. continue;
  268. }
  269. ptr++;
  270. if (strncmp ("so", ptr, 2) != 0) {
  271. continue;
  272. }
  273. desc = jack_drivers_get_descriptor (drivers, dir_entry->d_name);
  274. if (desc) {
  275. driver_list = jack_slist_append (driver_list, desc);
  276. }
  277. }
  278. err = closedir (dir_stream);
  279. if (err) {
  280. jack_error ("error closing driver directory %s: %s\n",
  281. driver_dir, strerror (errno));
  282. }
  283. if (!driver_list) {
  284. jack_error ("could not find any drivers in %s!\n", driver_dir);
  285. return NULL;
  286. }
  287. return driver_list;
  288. }
  289. static void copyright (FILE* file)
  290. {
  291. fprintf (file, "jackd " VERSION "\n"
  292. "Copyright 2001-2009 Paul Davis, Stephane Letz, Jack O'Quinn, Torben Hohn and others.\n"
  293. "jackd comes with ABSOLUTELY NO WARRANTY\n"
  294. "This is free software, and you are welcome to redistribute it\n"
  295. "under certain conditions; see the file COPYING for details\n\n");
  296. }
  297. static void usage (FILE *file)
  298. {
  299. copyright (file);
  300. fprintf (file, "\n"
  301. "usage: jackd [ --no-realtime OR -r ]\n"
  302. " [ --realtime OR -R [ --realtime-priority OR -P priority ] ]\n"
  303. " (the two previous arguments are mutually exclusive. The default is --realtime)\n"
  304. " [ --name OR -n server-name ]\n"
  305. " [ --no-mlock OR -m ]\n"
  306. " [ --unlock OR -u ]\n"
  307. " [ --timeout OR -t client-timeout-in-msecs ]\n"
  308. " [ --port-max OR -p maximum-number-of-ports]\n"
  309. " [ --debug-timer OR -D ]\n"
  310. " [ --no-sanity-checks OR -N ]\n"
  311. " [ --verbose OR -v ]\n"
  312. " [ --clocksource OR -c [ c(ycle) | h(pet) | s(ystem) ]\n"
  313. " [ --replace-registry ]\n"
  314. " [ --silent OR -s ]\n"
  315. " [ --version OR -V ]\n"
  316. " [ --nozombies OR -Z ]\n"
  317. " -d backend [ ... backend args ... ]\n"
  318. #ifdef __APPLE__
  319. " Available backends may include: coreaudio, dummy, net, portaudio.\n\n"
  320. #else
  321. " Available backends may include: alsa, dummy, freebob, firewire, net, oss, sun, or portaudio.\n\n"
  322. #endif
  323. " jackd -d backend --help\n"
  324. " to display options for each backend\n\n");
  325. }
  326. static jack_driver_desc_t *
  327. jack_find_driver_descriptor (const char * name)
  328. {
  329. jack_driver_desc_t * desc = 0;
  330. JSList * node;
  331. for (node = drivers; node; node = jack_slist_next (node)) {
  332. desc = (jack_driver_desc_t *) node->data;
  333. if (strcmp (desc->name, name) != 0) {
  334. desc = NULL;
  335. } else {
  336. break;
  337. }
  338. }
  339. return desc;
  340. }
  341. static void
  342. jack_cleanup_files (const char *server_name)
  343. {
  344. DIR *dir;
  345. struct dirent *dirent;
  346. char dir_name[PATH_MAX+1] = "";
  347. jack_server_dir (server_name, dir_name);
  348. /* On termination, we remove all files that jackd creates so
  349. * subsequent attempts to start jackd will not believe that an
  350. * instance is already running. If the server crashes or is
  351. * terminated with SIGKILL, this is not possible. So, cleanup
  352. * is also attempted when jackd starts.
  353. *
  354. * There are several tricky issues. First, the previous JACK
  355. * server may have run for a different user ID, so its files
  356. * may be inaccessible. This is handled by using a separate
  357. * JACK_TMP_DIR subdirectory for each user. Second, there may
  358. * be other servers running with different names. Each gets
  359. * its own subdirectory within the per-user directory. The
  360. * current process has already registered as `server_name', so
  361. * we know there is no other server actively using that name.
  362. */
  363. /* nothing to do if the server directory does not exist */
  364. if ((dir = opendir (dir_name)) == NULL) {
  365. return;
  366. }
  367. /* unlink all the files in this directory, they are mine */
  368. while ((dirent = readdir (dir)) != NULL) {
  369. char fullpath[PATH_MAX+1];
  370. if ((strcmp (dirent->d_name, ".") == 0)
  371. || (strcmp (dirent->d_name, "..") == 0)) {
  372. continue;
  373. }
  374. snprintf (fullpath, sizeof (fullpath), "%s/%s",
  375. dir_name, dirent->d_name);
  376. if (unlink (fullpath)) {
  377. jack_error ("cannot unlink `%s' (%s)", fullpath,
  378. strerror (errno));
  379. }
  380. }
  381. closedir (dir);
  382. /* now, delete the per-server subdirectory, itself */
  383. if (rmdir (dir_name)) {
  384. jack_error ("cannot remove `%s' (%s)", dir_name,
  385. strerror (errno));
  386. }
  387. /* finally, delete the per-user subdirectory, if empty */
  388. if (rmdir (jack_user_dir ())) {
  389. if (errno != ENOTEMPTY) {
  390. jack_error ("cannot remove `%s' (%s)",
  391. jack_user_dir (), strerror (errno));
  392. }
  393. }
  394. }
  395. static void
  396. maybe_use_capabilities ()
  397. {
  398. #ifdef USE_CAPABILITIES
  399. int status;
  400. /* check to see if there is a pipe in the right descriptor */
  401. if ((status = fstat (PIPE_WRITE_FD, &pipe_stat)) == 0 &&
  402. S_ISFIFO(pipe_stat.st_mode)) {
  403. /* tell jackstart we are up and running */
  404. char c = 1;
  405. if (write (PIPE_WRITE_FD, &c, 1) != 1) {
  406. jack_error ("cannot write to jackstart sync "
  407. "pipe %d (%s)", PIPE_WRITE_FD,
  408. strerror (errno));
  409. }
  410. if (close(PIPE_WRITE_FD) != 0) {
  411. jack_error("jackd: error on startup pipe close: %s",
  412. strerror (errno));
  413. } else {
  414. /* wait for jackstart process to set our capabilities */
  415. if (wait (&status) == -1) {
  416. jack_error ("jackd: wait for startup "
  417. "process exit failed");
  418. }
  419. if (!WIFEXITED (status) || WEXITSTATUS (status)) {
  420. jack_error ("jackd: jackstart did not "
  421. "exit cleanly");
  422. exit (1);
  423. }
  424. }
  425. }
  426. #endif /* USE_CAPABILITIES */
  427. }
  428. int
  429. main (int argc, char *argv[])
  430. {
  431. jack_driver_desc_t * desc;
  432. int replace_registry = 0;
  433. int do_sanity_checks = 1;
  434. int show_version = 0;
  435. const char *options = "-d:P:uvshVrRZTFlt:mM:n:Np:c:";
  436. struct option long_options[] =
  437. {
  438. /* keep ordered by single-letter option code */
  439. { "clock-source", 1, 0, 'c' },
  440. { "driver", 1, 0, 'd' },
  441. { "help", 0, 0, 'h' },
  442. { "tmpdir-location", 0, 0, 'l' },
  443. { "no-mlock", 0, 0, 'm' },
  444. { "midi-bufsize", 1, 0, 'M' },
  445. { "name", 1, 0, 'n' },
  446. { "no-sanity-checks", 0, 0, 'N' },
  447. { "port-max", 1, 0, 'p' },
  448. { "realtime-priority", 1, 0, 'P' },
  449. { "no-realtime", 0, 0, 'r' },
  450. { "realtime", 0, 0, 'R' },
  451. { "replace-registry", 0, &replace_registry, 0 },
  452. { "silent", 0, 0, 's' },
  453. { "timeout", 1, 0, 't' },
  454. { "temporary", 0, 0, 'T' },
  455. { "unlock", 0, 0, 'u' },
  456. { "version", 0, 0, 'V' },
  457. { "verbose", 0, 0, 'v' },
  458. { "nozombies", 0, 0, 'Z' },
  459. { 0, 0, 0, 0 }
  460. };
  461. int opt = 0;
  462. int option_index = 0;
  463. int seen_driver = 0;
  464. char *driver_name = NULL;
  465. char **driver_args = NULL;
  466. JSList * driver_params;
  467. size_t midi_buffer_size = 0;
  468. int driver_nargs = 1;
  469. int i;
  470. int rc;
  471. setvbuf (stdout, NULL, _IOLBF, 0);
  472. maybe_use_capabilities ();
  473. opterr = 0;
  474. while (!seen_driver &&
  475. (opt = getopt_long (argc, argv, options,
  476. long_options, &option_index)) != EOF) {
  477. switch (opt) {
  478. case 'c':
  479. if (tolower (optarg[0]) == 'h') {
  480. clock_source = JACK_TIMER_HPET;
  481. } else if (tolower (optarg[0]) == 'c') {
  482. clock_source = JACK_TIMER_CYCLE_COUNTER;
  483. } else if (tolower (optarg[0]) == 's') {
  484. clock_source = JACK_TIMER_SYSTEM_CLOCK;
  485. } else {
  486. usage (stderr);
  487. return -1;
  488. }
  489. break;
  490. case 'd':
  491. seen_driver = 1;
  492. driver_name = optarg;
  493. break;
  494. case 'D':
  495. frame_time_offset = JACK_MAX_FRAMES - atoi(optarg);
  496. break;
  497. case 'l':
  498. /* special flag to allow libjack to determine jackd's idea of where tmpdir is */
  499. printf ("%s\n", jack_tmpdir);
  500. exit (0);
  501. case 'm':
  502. do_mlock = 0;
  503. break;
  504. case 'M':
  505. midi_buffer_size = (unsigned int) atol (optarg);
  506. break;
  507. case 'n':
  508. server_name = optarg;
  509. break;
  510. case 'N':
  511. do_sanity_checks = 0;
  512. break;
  513. case 'p':
  514. port_max = (unsigned int) atol (optarg);
  515. break;
  516. case 'P':
  517. realtime_priority = atoi (optarg);
  518. break;
  519. case 'r':
  520. realtime = 0;
  521. break;
  522. case 'R':
  523. /* this is now the default */
  524. realtime = 1;
  525. break;
  526. case 's':
  527. jack_set_error_function (silent_jack_error_callback);
  528. break;
  529. case 'T':
  530. temporary = 1;
  531. break;
  532. case 't':
  533. client_timeout = atoi (optarg);
  534. break;
  535. case 'u':
  536. do_unlock = 1;
  537. break;
  538. case 'v':
  539. verbose = 1;
  540. break;
  541. case 'V':
  542. show_version = 1;
  543. break;
  544. case 'Z':
  545. nozombies = 1;
  546. break;
  547. default:
  548. jack_error ("Unknown option character %c",
  549. optopt);
  550. /*fallthru*/
  551. case 'h':
  552. usage (stdout);
  553. return -1;
  554. }
  555. }
  556. if (show_version) {
  557. printf ( "jackd version " VERSION
  558. " tmpdir " DEFAULT_TMP_DIR
  559. " protocol " PROTOCOL_VERSION
  560. "\n");
  561. return 0;
  562. }
  563. copyright (stdout);
  564. if (do_sanity_checks && (0 < sanitycheck (realtime, (clock_source == JACK_TIMER_CYCLE_COUNTER)))) {
  565. return -1;
  566. }
  567. if (realtime && (client_timeout >= JACKD_WATCHDOG_TIMEOUT)) {
  568. usage (stderr);
  569. fprintf (stderr, "In realtime mode (-R) the client timeout must be smaller than the watchdog timeout (%ims).\n", JACKD_WATCHDOG_TIMEOUT);
  570. exit (1);
  571. }
  572. if (!seen_driver) {
  573. usage (stderr);
  574. exit (1);
  575. }
  576. drivers = jack_drivers_load ();
  577. if (!drivers) {
  578. fprintf (stderr, "jackd: no drivers found; exiting\n");
  579. exit (1);
  580. }
  581. if (midi_buffer_size != 0) {
  582. jack_port_type_info_t* port_type = &jack_builtin_port_types[JACK_MIDI_PORT_TYPE];
  583. port_type->buffer_size = midi_buffer_size * jack_midi_internal_event_size ();
  584. port_type->buffer_scale_factor = -1;
  585. if (verbose) {
  586. fprintf (stderr, "Set MIDI buffer size to %u bytes\n", port_type->buffer_size);
  587. }
  588. }
  589. desc = jack_find_driver_descriptor (driver_name);
  590. if (!desc) {
  591. fprintf (stderr, "jackd: unknown driver '%s'\n", driver_name);
  592. exit (1);
  593. }
  594. if (optind < argc) {
  595. driver_nargs = 1 + argc - optind;
  596. } else {
  597. driver_nargs = 1;
  598. }
  599. if (driver_nargs == 0) {
  600. fprintf (stderr, "No driver specified ... hmm. JACK won't do"
  601. " anything when run like this.\n");
  602. return -1;
  603. }
  604. driver_args = (char **) malloc (sizeof (char *) * driver_nargs);
  605. driver_args[0] = driver_name;
  606. for (i = 1; i < driver_nargs; i++) {
  607. driver_args[i] = argv[optind++];
  608. }
  609. if (jack_parse_driver_params (desc, driver_nargs,
  610. driver_args, &driver_params)) {
  611. exit (0);
  612. }
  613. if (server_name == NULL)
  614. server_name = jack_default_server_name ();
  615. rc = jack_register_server (server_name, replace_registry);
  616. switch (rc) {
  617. case EEXIST:
  618. fprintf (stderr, "`%s' server already active\n", server_name);
  619. exit (1);
  620. case ENOSPC:
  621. fprintf (stderr, "too many servers already active\n");
  622. exit (2);
  623. case ENOMEM:
  624. fprintf (stderr, "no access to shm registry\n");
  625. exit (3);
  626. default:
  627. if (verbose)
  628. fprintf (stderr, "server `%s' registered\n",
  629. server_name);
  630. }
  631. /* clean up shared memory and files from any previous
  632. * instance of this server name */
  633. jack_cleanup_shm ();
  634. jack_cleanup_files (server_name);
  635. /* run the server engine until it terminates */
  636. jack_main (desc, driver_params);
  637. /* clean up shared memory and files from this server instance */
  638. if (verbose)
  639. fprintf (stderr, "cleaning up shared memory\n");
  640. jack_cleanup_shm ();
  641. if (verbose)
  642. fprintf (stderr, "cleaning up files\n");
  643. jack_cleanup_files (server_name);
  644. if (verbose)
  645. fprintf (stderr, "unregistering server `%s'\n", server_name);
  646. jack_unregister_server (server_name);
  647. exit (0);
  648. }