2013-12-02  Ludovic Courtès  <ludo@gnu.org>

	build: Change 'respawn.sh' test to use two services.
	* tests/respawn.sh: Add second service.  Use
	  'assert_killed_service_is_respawned' on both services.

	dmd: SIGCHLD handler iterates over all the dead processes.
	* modules/dmd/service.scm (waitpid*): New procedure.
	  (respawn-service): Use it, and pass WNOHANG.  Use 'match', and loop
	  until 'waitpid*' returns a PID of 0.

	dmd: Don't get SIGCHLD for processes that stop.
	* modules/dmd/service.scm: Pass SA_NOCLDSTOP as a 'sigaction' flag.

	Change log file to $localstatedir/log/dmd.log when running as 'root'.
	* modules/dmd/support.scm (default-logfile): Add '/log'.
	* modules/dmd/comm.scm (start-logging): Make sure FILE's directory
	  exists.

2013-12-01  Ludovic Courtès  <ludo@gnu.org>

	Clarify SIGCHLD handler.
	* modules/dmd/service.scm (find-service): New function.
	  (respawn-service): Use it, and fold the body of 'handler' into
	  'respawn-service'.  Emit warning about unknown child processes.

	build: Add test for respawnable services.
	* tests/respawn.sh: New file.
	* Makefile.am (TESTS): Add it.
	  (AM_TESTS_ENVIRONMENT): Set 'SHELL' variable.

	dmd: Work around unreliable signal delivery.
	* modules/dmd.scm (main): Add 'sigaction' and 'alarm' call to wake up
	  every second.  Argh.

	Use 'EINTR-safe' for 'accept' calls.
	* modules/dmd/service.scm (EINTR-safe): Move to...
	* modules/dmd/support.scm (EINTR-safe): ... here.
	* modules/dmd.scm (main): Use 'EINTR-safe' instead of
	  'catch-system-error' for 'accept' calls.

2013-11-30  Ludovic Courtès  <ludo@gnu.org>

	build: Change test to build a local log file rather than under $HOME.
	* tests/basic.sh: Use a temporary log file under $PWD.

	build: Add a basic test.
	* tests/basic.sh: New file.
	* configure.ac: Add 'color-tests' Automake option.
	* Makefile.am (TESTS, TEST_EXTENSIONS, AM_TESTS_ENVIRONMENT,
	  SH_LOG_COMPILER, AM_SH_LOG_FLAGS): New variables.
	  (EXTRA_DIST): Add $(TESTS).

	build: Generate 'ChangeLog' upon 'make dist'.
	* ChangeLog: Rename to...
	* ChangeLog-2003: ... this.
	* ChangeLog: New file.
	* Makefile.am (EXTRA_DIST): Add 'ChangeLog-2003'.
	  (gen-ChangeLog, dist-hook): New targets.
	* build-aux/gitlog-to-changelog: New file, from Gnulib.

	Provide EINTR-safe versions of 'system' and 'system*' for Guile < 2.0.10.
	* modules/dmd/service.scm (EINTR-safe, system*, system): New
	  procedures.

	Update 'NEWS' for 0.1.

	Change 'NEWS' to Org-mode.

	Update 'README' and 'AUTHORS'.

	build: Use Automake's 'std-options' flag.
	* configure.ac: Add 'std-options' to 'AM_INIT_AUTOMAKE'.

	build: Make commands usable before install; relocate them upon install.
	* Makefile.am (install-exec-hook): New target.
	  (instantiate): Remove %DMDDIR%; use %modsrcdir% and %modbuilddir%
	  instead.
	* deco.in, dmd.in, halt.in, reboot.in: Use them instead of %DMDDIR%.

	build: Clean leftover 'halt' and 'reboot' files.
	* Makefile.am (CLEANFILES): Add $(sbin_SCRIPTS).

	doc: Switch license to GNU FDL 1.3+.
	* dmd.texi: Change @copying to FDL 1.3+.  Update master menu.
	  (GNU Free Documentation License): New appendix.
	* fdl-1.3.texi: New file.
	* Makefile.am (EXTRA_DIST): Add it.
	* COPYING.DOC: Remove.

	doc: Assorted improvements.
	* dmd.texi: Change title to "GNU dmd Manual".  Use @copying.  Add
	  directory entry for deco, reboot, and halt.  Set encoding to UTF-8.
	  Use @contents.
	  (Introduction): Fix cross-ref to Guile's Top node.
	  (deco and dmd): Update menu.
	  (Invoking dmd): Add reference to "Services".  Clarify text of
	  '--insecure'.  Remove '--silent'.  Give exact socket file name.
	  (Invoking deco): Improve wording an typography.  Remove non-existent
	  '--insecure' option.
	  (Invoking reboot, Invoking halt): New nodes.
	  (Services): Add cross-ref to GOOPS.  Mention the (dmd service) module.
	  (Service De- and Constructors): Use @var and @dots appropriately.
	  Update 'make-forkexec-constructor' documentation to mention closed
	  file descriptors.
	  (The dmd and unknown services): Use @table @code; remove redundant
	  @code.  Mention the execution environment for 'load'.

2013-11-29  Ludovic Courtès  <ludo@gnu.org>

	doc: Cosmetic updates.
	* dmd.texi (YEARS): Rename to...
	  (OLD-YEARS): ... this.
	  (NEW-YEARS): New variable.
	  Add myself as copyright holder, and add copyright line.
	  (Introduction): Mention use as an init system and as a user.  Link to
	  Guile's manual.
	  (Jump Start): Update socket file name.  Mention 'networking', not
	  'network'.  Remove the 'silent' and 'verbose' actions.
	  (Coding standards): Remove hint about formatting of 'if'.

	Add licensing and copyright information in '--version'.
	* modules/dmd/support.scm: Rewrite as UTF-8.
	  (display-version): Show copyright and licensing info.

	Add 'halt' and 'reboot' commands.
	* halt.in, reboot.in, modules/halt.scm, modules/reboot.scm: New files.
	* Makefile.am (sbin_SCRIPTS): New variable.
	  (templates): Add halt.in and reboot.in.
	  (dist_dmd_DATA): Add halt.scm and reboot.scm.
	  (maybe_executable): New variable.
	  (%:%.in): Use it.
	  (deco, dmd): Remove targets.

	build: Factorize socket directory handling.
	* Makefile.am (install-data-local): Use $(localstatedir), not
	  ${prefix}/var.  Change mode to 700, not 777.  Add '-'.
	  (install-data-hook): Remove.

	deco: Use line buffering for the input.
	* modules/deco.scm (main): Add 'setvbuf' call before receiving input.

	Have 'make-forkexec-constructor' close all file descriptors after 'fork'.
	* configure.ac: Check for '_SC_OPEN_MAX' and substitute it.
	* modules/dmd/system.scm.in (_SC_OPEN_MAX): New variable.
	  (sysconf, max-file-descriptors): New procedures.
	* modules/dmd/service.scm (make-forkexec-constructor): Close all the
	  file descriptors except stdout and stderr before calling 'execlp'.

2013-11-28  Ludovic Courtès  <ludo@gnu.org>

	dmd: The 'load' action loads in a fresh module.
	* modules/dmd.scm (make-dmd-user-module): Move to support.scm.
	  (main): Use 'load-in-user-module' instead of 'primitive-load' and
	  'make-dmd-user-module'.
	* modules/dmd/service.scm (dmd-service)[load]: Use
	  'load-in-user-module'.
	* modules/dmd/support.scm (make-dmd-user-module, load-in-user-module):
	  New procedures.

	Change SIGCHLD handler to dismiss services not backed by a process.
	* modules/dmd/service.scm (respawn-service)[handler]: Deal with
	  'running' slots that are not a number.

	build: Chmod 700 $localstatedir/run/dmd.
	* Makefile.am (install-data-hook): New target.

	Allow non-respawnable services to be stopped.
	* modules/dmd/service.scm (stop): Always clear the 'running' slot before
	  calling OBJ's 'stop'.  Restore its value upon exception.

	dmd: Fix race condition when a service's process dies immediately at startup.
	* modules/dmd/service.scm (start): Wrap call to OBJ's 'start' field in
	  'call-with-blocked-asyncs'.
	  (respawn-service): Disable services whose process just died, even if
	  the service is not respawnable.

2013-11-27  Ludovic Courtès  <ludo@gnu.org>

	Catch 'system-error' in 'make-forkexec-constructor'.
	* modules/dmd/service.scm (make-forkexec-constructor): Catch and handle
	  'system-error'.

	dmd: Catch 'system-error' exceptions in 'accept' call.
	* modules/dmd.scm (main): Wrap 'accept' call in 'catch-system-error'.

	build: Bump to 0.1.
	* configure.ac: Set version to 0.1.

	dmd: Evaluate the configuration file in a fresh module.
	* modules/dmd.scm (make-dmd-user-module): New procedure.
	  (main): Use it.  Load CONFIG-FILE with 'primitive-load', in the
	  context of a fresh module.
	* dmd.texi (Jump Start): Write "reads and evaluates".
	  (Invoking dmd): Likewise.  Make the evaluation context explicit.

	dmd: Adjust command reading from stdin.
	* modules/dmd.scm (main): Remove (not socket-file) case; call
	  'process-textual-commands' in that case.
	  (process-textual-commands): New procedure.

	system: Report the 'errno' value upon 'reboot' failure.
	* modules/dmd/system.scm.in (%libc-reboot): Call 'errno' upon failure,
	  and throw an exception.
	  (%libc-errno-pointer, errno): New procedures.

2013-11-25  Ludovic Courtès  <ludo@gnu.org>

	build: Ensure the templates are instantiated before anything is compiled.
	* Makefile.am (.scm.go): Change to...
	  (%.go:%.scm): ... this.  Add dependency on the instantiated
	  templates.

	deco: Remove '--insecure'.
	* modules/deco.scm (main): Remove '--insecure' option.

	dmd: Simplify output port handling.
	* modules/dmd/comm.scm: Unsplice code formerly in 'begin-dmd' form.
	  Strip export list.  Remove top-level call to 'set-current-output-port'.
	  (make-dmd-output-port): New procedure.
	  (dmd-output-port): Use it.
	  (silent, be-silent, be-verbose): Remove.
	* modules/dmd/service.scm (dmd-service): Remove the 'silent' and
	  'verbose' actions.
	* modules/dmd/support.scm (begin-dmd): Remove.
	* modules/dmd.scm (main): Call 'set-current-output-port' from here.
	  Remove use of 'be-silent'.  '--silent' and '--quiet' are now no-ops.

	Remove now-useless variable.
	* modules/dmd/comm.scm (terminating-string): Remove.

2013-11-24  Ludovic Courtès  <ludo@gnu.org>

	Avoid use of deprecated interface to procedure arities.
	* modules/dmd/support.scm (can-apply?): Use 'procedure-minimum-arity'
	  instead of 'procedure-property'.

	dmd: Write to stdout only as a last resort.
	* modules/dmd/comm.scm (dmd-output-port): When (%current-client-socket)
	  is true, send data only to that.

	Use a single socket for communication; change to an sexp-based protocol.
	* modules/dmd/comm.scm (<sender>, initialize, send-data, <receiver>,
	  initialize, receive-data): Remove.
	  (<dmd-command>): New record type.
	  (dmd-command, open-connection, read-command, write-command): New
	  procedures.
	  (extra-output-sender, open-extra-sender, close-extra-sender,
	  without-extra-output): Remove.
	  (%current-client-socket): New variable.
	* modules/dmd/service.scm (respawn-service): Remove use of
	  'without-extra-output'.
	* modules/dmd/support.scm (default-socket-file): Change to /socket.
	  (default-deco-socket-file): Remove.
	* modules/deco.scm (main): Remove --result-socket option.  Use
	  'open-connection' instead of <sender> and <receiver>.  Use
	  'write-command' instead of 'send-data'.  Use 'read-line' instead of
	  'receive-data'.
	* modules/dmd.scm (open-server-socket): New procedure.
	  (main): Use it.  Remove handshake.
	  (process-connection): New procedure.
	  (process-command): Expect COMMAND to be a <dmd-command>; use 'match'.

	Fix invocation of dmd's and deco's 'main' procedures.
	* modules/deco.scm (main): Turn 'args' into a rest argument.
	  Remove invocation at end of file.
	* modules/dmd.scm (main): Likewise.
	  Remove invocation at end of file.

2013-11-20  Ludovic Courtès  <ludo@gnu.org>

	dmd-service: Really halt/power-off.
	* modules/dmd/service.scm (dmd-service): Change 'halt' and 'power-off'
	  handler for 'quit' to accept one argument.  Move message to the handler.
	* modules/dmd.scm (process-command): Add "Rebooting..." message before
	  call to 'reboot'.

	build: Make 'deco' and 'dmd' executable.
	* Makefile.am (deco, dmd): New targets.

	deco: Gracefully handle not-enough-arguments conditions.
	* modules/deco.scm (main): Gracefully handle not-enough-arguments
	  conditions.

2013-11-14  Ludovic Courtès  <ludo@gnu.org>

	dmd-service: Add 'halt' and 'power-off' actions.
	* modules/dmd/service.scm (shutdown-services): New procedure.  Code
	  moved from...
	  (dmd-service)[#:stop]: ... here.
	  [#:actions]: Add 'halt' and 'power-off'.

	'deco stop dmd' reboots instead of panicking.
	* modules/dmd.scm (process-command): In 'quit' handler: when running as
	  root, call 'reboot' instead of 'quit'.
	* modules/dmd/service.scm (dmd-service)[daemonize]: Exit with
	  'primitive-exit'.

	dmd-service: Use 'when' in contexts for effect.
	* modules/dmd/service.scm (dmd-service): Use 'when' instead of 'if' or
	  'and' when in effect context.

	Add (dmd system).
	* modules/dmd/system.scm.in: New file.
	* Makefile.am (templates): Add it.
	  (nodist_dmdsub_DATA): Add modules/dmd/system.{scm,go}.
	* configure.ac: Bump Autoconf requirement, for 'AC_COMPUTE_INT'.  Use
	  'AC_CANONICAL_HOST'.  Add 'AC_COMPUTE_INT' invocations for RB_*
	  constants.  Output modules/dmd/system.scm.

2013-11-03  Ludovic Courtès  <ludo@gnu.org>

	Upgrade to GPLv3+.

	Augment '.gitignore'.

	Change '--help' output to match current GNU standard.
	* modules/dmd/config.scm.in (package-url): New variable.
	* Makefile.am (instantiate): Substitute %PACKAGE_URL%.
	* modules/dmd/args.scm (process-args): Change '--help' message to comply
	  with current GNU standards.

	Commands don't start a shell, and avoid auto-compilation.
	* deco.in, dmd.in: Rewrite in Scheme; add '--no-auto-compile'.

	Install the current locale.
	* modules/deco.scm (main): Add 'setlocale' call.
	* modules/dmd.scm (main): Likewise.

	Change '--version' output to match current GNU standard.
	* modules/dmd/config.scm.in (package-name): New variable.
	* Makefile.am (instantiate): Substitute %PACKAGE_NAME%.
	* modules/dmd/support.scm (display-version): Use the standard GNU
	  format.

2013-09-27  Ludovic Courtès  <ludo@gnu.org>

	Honor --localstatedir; change socket file to be independent from the user.
	* modules/dmd/support.scm (default-socket-dir): Change to be independent
	  of the calling user.  Use '%localstatedir', not 'Prefix-dir'.
	  (default-persistency-state-file): Use '%localstatedir'.

	Use 'lambda*' instead of 'opt-lambda'.
	* modules/dmd/support.scm (opt-lambda): Remove.
	* modules/dmd/service.scm (make-kill-destructor, dmd-service): Use
	  'lambda*' instead of 'opt-lambda'.

	doc: Use @ifnottex, not @ifinfo, for the 'Top' node.
	* dmd.texi (Top): Use @ifnottex instead of @ifinfo, as recommended by
	  makeinfo.

2013-09-21  Ludovic Courtès  <ludo@gnu.org>

	Update 'NEWS'.

	Fix typo in 'local-output'.
	* modules/dmd/support.scm (local-output): Actually write to the current
	  output port.

	build: Use the package bug-report address.
	* Makefile.am (instantiate): Add @PACKAGE_BUGREPORT@.
	* modules/dmd/config.scm.in (bug-address): Use @PACKAGE_BUGREPORT@.

	build: Use Automake with '-Wall -Wno-portability'.
	* configure.ac: Use '-Wall -Wno-portability' for Automake.

2013-09-20  Ludovic Courtès  <ludo@gnu.org>

	Update '.gitignore'.

	Become the session leader when forking a service.
	* modules/dmd/service.scm (make-forkexec-constructor): Call 'setsid'.

	service: Rewrite 'make-actions' as a 'syntax-rules' macro.
	* modules/dmd/service.scm (make-actions): Move above first use; rewrite
	  using 'syntax-rules'.

2013-09-19  Ludovic Courtès  <ludo@gnu.org>

	build: Store 'dmd.log' under $localstatedir.
	* Makefile.am (instantiate): Add %localstatedir%.
	* modules/dmd/config.scm.in (%localstatedir): New variable.
	* modules/dmd/support.scm (default-logfile): As root, set to
	  (string-append %localstatedir "/dmd.log").

	Remove generated file.
	* modules/dmd/config.scm: Remove.

	build: Substitute $(GUILE) in scripts.
	* Makefile.am (instantiate): Substitute %GUILE%.
	* deco.in, dmd.in: Use %GUILE%.

	build: Factorize sed expression for template instantiation.
	* Makefile.am (instantiate): New variable.
	  (%, modules/dmd/config.scm): Use it.

	Consistently use 'make-forkexec-constructor'.
	* dmd.texi (Service De- and Constructors): Change
	  'make-childexec-constructor' to 'make-forkexec-constructor'.
	* examples/wolfgangj.scm: Likewise.

2013-09-13  Ludovic Courtès  <ludo@gnu.org>

	build: Use $(SED).
	* configure.ac: Add 'AC_PROG_SED'.
	* Makefile.am: Use it.

	build: Fix 'distcheck'.
	* Makefile.am (dmd_DATA): Rename to...
	  (dist_dmd_DATA): ...this.
	  (nodist_dmd_DATA): Adjust accordingly.
	  (dmdsub_DATA): Rename to...
	  (dist_dmdsub_DATA): ... this.
	  (nodist_dmdsub_DATA): Adjust accordingly.
	  (CLEANFILES): Add $(bin_SCRIPTS).
	  (modules/dmd/config.scm): New target.
	  (BUILT_SOURCES): New variable.

	doc: Use better name for the Texinfo directory entry.
	* dmd.texi: Change direntry name to "dmd".

2013-02-14  Ludovic Courtès  <ludo@gnu.org>

	build: Compile and install `.go' files.
	* Makefile.am (nodist_dmd_DATA): New variable.
	  (nodist_dmdsub_DATA): Add .go files.
	  (.scm.go): New rule.
	  (SUFFIXES, dmd_install_go_files): New variable.
	  ($(dmd_install_go_files)): New rule.
	* configure.ac: Check for `guild'.
	* deco.in, dmd.in: Set `GUILE_LOAD_COMPILED_PATH'.

2013-02-10  Ludovic Courtès  <ludo@gnu.org>

	build: Use modern `configure.ac'.
	* configure.in: Rename to...
	* configure.ac: ... this.  Use current `AC_INIT' and `AM_INIT_AUTOMAKE'
	  invocations.  Add `AC_CONFIG_SRCDIR' and `AC_CONFIG_AUX_DIR'.

2013-02-09  Ludovic Courtès  <ludo@gnu.org>

	Use modules instead of `load'.
	* args.scm, comm.scm, config.scm.in, runlevel.scm, service.scm,
	  support.scm: Move under modules/dmd and turn into modules.  Fix
	  various small issues.
	* deco.scm, dmd.scm: Move under modules/ and turn into modules.  Shuffle
	  around global variables to other places.
	* self.scm: Remove.  Move `dmd-service' variable to
	  modules/dmd/service.scm.
	* configure.in: Adjust `AC_INIT' call accordingly.  Use
	  `AC_PROG_MKDIR_P'.
	* Makefile.am (templates): Adjust accordingly.
	  (dmd_data): Remove.
	  (dmd_DATA, dmdsubdir, dmdsub_DATA, nodist_dmdsub_DATA): New
	  variables.
	  (%: %.in): Make the target's parent directory first.

	Remove more generated files.

	Remove uses of `debug-enable'.
	* deco.scm, dmd.scm: Remove `debug-enable'.

	build: Remove generated files.

	Adjust to Guile 2.0 macrology.
	* support.scm (define-syntax-rule): Remove.
	  (begin-dmd): Implement using `syntax-case'.
	* dmd.scm, deco.scm: Don't use (ice-9 syncase).
	* runlevel.scm (enter): Fix erroneous `let' form.
