add daemonizing support to console-client, initscript
Hi, [PATCH 1/3] console-client: add daemonizing support This patch adds daemonizing support to console-client. [PATCH 2/3] Add (build) dependency on libdaemon [PATCH 3/3] Add an initscript for the hurd console These are for the debian repository only. They add the build and runtime dependency and an initscript for the hurd-console. Justus
[PATCH 2/3] Add (build) dependency on libdaemon
--- debian/control |6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/debian/control b/debian/control index eafb7a6..63b6889 100644 --- a/debian/control +++ b/debian/control @@ -7,7 +7,7 @@ Build-Depends: mig (>= 1.3-2), gnumach-dev (>= 2:1.3.99.dfsg.cvs20070526), libc0.3-dev (>= 2.13-38~), texinfo, texi2html, libncursesw5-dev, debhelper (>= 7.0.50~), gcc-4.7, dpkg (>= 1.15.4) | install-info, autoconf, libparted-dev, libpciaccess-dev, libx11-dev, x11proto-core-dev, pkg-config, - xkb-data, gawk, flex, bison, autotools-dev + xkb-data, gawk, flex, bison, autotools-dev, libdaemon-dev Uploaders: Jeff Bailey , Neal H. Walfield , Michael Banck , Samuel Thibault @@ -27,7 +27,7 @@ Description: GNU Hurd (libraries) Package: hurd Essential: yes Pre-Depends: hurd-libs0.3 -Depends: ${misc:Depends}, hurd-libs0.3 (= ${binary:Version}), sysv-rc, netdde (>= 0.0.20120518~), ${shlibs:Depends}, xkb-data +Depends: ${misc:Depends}, hurd-libs0.3 (= ${binary:Version}), sysv-rc, netdde (>= 0.0.20120518~), ${shlibs:Depends}, xkb-data, libdaemon0 Breaks: gnumach (<< 2:1.3.99.dfsg.cvs20070526-1), libc0.3 (<< 2.11.2-12), netdde (<< 0.0.20121127-2) Suggests: hurd-doc Recommends: bf-utf-source @@ -80,7 +80,7 @@ Package-Type: udeb Priority: optional Section: debian-installer Architecture: hurd-any -Depends: ${misc:Depends}, hurd-libs0.3-udeb (= ${binary:Version}), xkb-data-udeb +Depends: ${misc:Depends}, hurd-libs0.3-udeb (= ${binary:Version}), xkb-data-udeb, libdaemon0 Provides: hurd, ext2-modules, fat-modules, ipv6-modules, isofs-modules, loop-modules, mouse-modules, nfs-modules, socket-modules, ufs-modules Description: GNU Hurd - udeb This is the GNU Hurd udeb package. It contains essential system software and -- 1.7.10.4
[PATCH 1/3] console-client: add daemonizing support
This patch adds daemonizing support using libdaemon. * console-client/console.c (daemonize): New variable. (options): Add --daemonize argument. (parse_opt): Handle --daemonize argument. (daemon_error): New error(3) like macro. (main): Daemonize. --- console-client/Makefile |2 +- console-client/console.c | 104 +++--- 2 files changed, 100 insertions(+), 6 deletions(-) diff --git a/console-client/Makefile b/console-client/Makefile index 69a7e37..0ad7a53 100644 --- a/console-client/Makefile +++ b/console-client/Makefile @@ -37,7 +37,7 @@ SRCS = $(CONSOLE_SRCS) \ VPATH += $(srcdir)/xkb OBJS = $(addsuffix .o,$(basename $(notdir $(SRCS kdioctlServer.o HURDLIBS = cons ports netfs fshelp iohelp ihash shouldbeinlibc -LDLIBS = -ldl -lpthread +LDLIBS = -ldl -lpthread -ldaemon module-dir = $(libdir)/hurd/console console-LDFLAGS = -Wl,-E diff --git a/console-client/console.c b/console-client/console.c index 7c9a880..7dd7a00 100644 --- a/console-client/console.c +++ b/console-client/console.c @@ -26,6 +26,7 @@ #include #include +#include #include #include @@ -61,6 +62,8 @@ static cons_t saved_cons; set. */ static char *console_node; +/* If set, the client will daemonize. */ +static int daemonize; /* Callbacks for input source drivers. */ @@ -516,6 +519,8 @@ cons_vcons_set_mousecursor_status (vcons_t vcons, int status) } +#define DAEMONIZE_KEY 0x80 /* !isascii (DAEMONIZE_KEY), so no short option. */ + /* Console-specific options. */ static const struct argp_option options[] = @@ -524,6 +529,7 @@ options[] = {"driver", 'd', "NAME", 0, "Add driver NAME to the console" }, {"console-node", 'c', "FILE", OPTION_ARG_OPTIONAL, "Set a translator on the node FILE (default: " DEFAULT_CONSOLE_NODE ")" }, +{"daemonize", DAEMONIZE_KEY, NULL, 0, "daemonize the console client"}, {0} }; @@ -577,7 +583,11 @@ parse_opt (int key, char *arg, struct argp_state *state) if (!console_node) return ENOMEM; break; - + +case DAEMONIZE_KEY: + daemonize = 1; + break; + case ARGP_KEY_SUCCESS: if (!devcount) { @@ -598,6 +608,28 @@ static const struct argp_child startup_children[] = static struct argp startup_argp = {options, parse_opt, 0, 0, startup_children}; +#define daemon_error(status, errnum, format, args...) \ + do\ +{ \ + if (daemonize)\ +{ \ + if (errnum) \ +daemon_log (LOG_ERR, format ": %s", ##args, \ +strerror(errnum)); \ + else \ +daemon_log (LOG_ERR, format, ##args); \ + if (status) \ +{ \ + /* Signal parent. */ \ + daemon_retval_send (status); \ + return 0; \ +} \ +} \ + else \ +error (status, errnum, format, ##args); \ +} \ + while (0); + int main (int argc, char *argv[]) { @@ -609,9 +641,67 @@ main (int argc, char *argv[]) /* Parse our command line. This shouldn't ever return an error. */ argp_parse (&startup_argp, argc, argv, ARGP_IN_ORDER, 0, 0); + if (daemonize) +{ + /* Reset signal handlers. */ + if (daemon_reset_sigs (-1) < 0) +error (1, errno, "Failed to reset all signal handlers"); + + /* Unblock signals. */ + if (daemon_unblock_sigs (-1) < 0) +error (1, errno, "Failed to unblock all signals"); + + /* Set indetification string for the daemon for both syslog and + PID file. */ + daemon_pid_file_ident = daemon_log_ident = \ +daemon_ident_from_argv0 (argv[0]); + + /* Check that the daemon is not run twice at the same time. */ + pid_t pid; + if ((pid = daemon_pid_file_is_running ()) >= 0) +error (1, errno, "Daemon already running on PID file %u", pid); + + /* Prepare for return value passing from the initialization + procedure of the daemon process. */ + if (daemon_retval_init () < 0) +
[PATCH 3/3] Add an initscript for the hurd console
--- debian/changelog |1 + debian/hurd.hurd-console.init | 121 + 2 files changed, 122 insertions(+) create mode 100644 debian/hurd.hurd-console.init diff --git a/debian/changelog b/debian/changelog index 81b9e56..adde108 100644 --- a/debian/changelog +++ b/debian/changelog @@ -2,6 +2,7 @@ hurd (20130707-2) UNRELEASED; urgency=low [ Justus Winter ] * Include the umount utility in hurd and hurd-udeb. + * Add an initscript for hurd-console. [ Samuel Thibault ] * Bump Standards-Version to 3.9.4 (no changes). diff --git a/debian/hurd.hurd-console.init b/debian/hurd.hurd-console.init new file mode 100644 index 000..bb15b8b --- /dev/null +++ b/debian/hurd.hurd-console.init @@ -0,0 +1,121 @@ +#! /bin/sh +### BEGIN INIT INFO +# Provides: hurd-console +# Required-Start:$all +# Required-Stop: +# Default-Start: 1 2 3 4 5 +# Default-Stop: 0 6 +# Short-Description: Example initscript +# Description: This file should be used to construct scripts to be +#placed in /etc/init.d. +### END INIT INFO + +# Author: Justus Winter <4win...@informatik.uni-hamburg.de> + +# PATH should only include /usr/* if it runs after the mountnfs.sh script +PATH=/sbin:/bin +DESC="Hurd console multiplexer" +NAME=console +DAEMON=/bin/$NAME +DAEMON_ARGS="--daemonize -D /home/teythoon/repos/hurd-upstream/console-client -d current_vcs -c /dev/vcs" +PIDFILE=/var/run/$NAME.pid +SCRIPTNAME=/etc/init.d/hurd-$NAME + +# Exit if the package is not installed +[ -x "$DAEMON" ] || exit 0 + +# Read configuration variable file if it is present +[ -r /etc/default/hurd-$NAME ] && . /etc/default/hurd-$NAME + +# Augment the arguments. +DAEMON_ARGS="${DAEMON_ARGS} ${DISPLAY} ${KBD} ${KBD_REPEAT} \ + ${SPEAKER} ${MOUSE} ${MOUSE_REPEAT}" + +# Load the VERBOSE setting and other rcS variables +. /lib/init/vars.sh + +# Define LSB log_* functions. +# Depend on lsb-base (>= 3.2-14) to ensure that this file is present +# and status_of_proc is working. +. /lib/lsb/init-functions + +# +# Function that starts the daemon/service +# +do_start() +{ + # Return + # 0 if daemon has been started + # 1 if daemon was already running + # 2 if daemon could not be started + start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \ + || return 1 + start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- \ + $DAEMON_ARGS \ + || return 2 +} + +# +# Function that stops the daemon/service +# +do_stop() +{ + # Return + # 0 if daemon has been stopped + # 1 if daemon was already stopped + # 2 if daemon could not be stopped + # other if a failure occurred + start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME + RETVAL="$?" + + [ "$?" = 2 ] && return 2 + # Many daemons don't delete their pidfiles when they exit. + #rm -f $PIDFILE + return "$RETVAL" +} + +case "$1" in + start) + [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "hurd-$NAME" + do_start + case "$?" in + 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; + 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; + esac + ;; + stop) + [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "hurd-$NAME" + do_stop + case "$?" in + 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; + 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; + esac + ;; + status) + status_of_proc "$DAEMON" "hurd-$NAME" && exit 0 || exit $? + ;; + restart|force-reload) + log_daemon_msg "Restarting $DESC" "hurd-$NAME" + do_stop + case "$?" in + 0|1) + do_start + case "$?" in + 0) log_end_msg 0 ;; + 1) log_end_msg 1 ;; # Old process is still running + *) log_end_msg 1 ;; # Failed to start + esac + ;; + *) + # Failed to stop + log_end_msg 1 + ;; + esac + ;; + *) + echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2 + exit 3 + ;; +esac + +: -- 1.7.10.4
Re: [PATCH 3/3] Add an initscript for the hurd console
Quoting Justus Winter (2013-07-17 13:09:06) > [...] > +DAEMON_ARGS="--daemonize -D > /home/teythoon/repos/hurd-upstream/console-client -d current_vcs -c /dev/vcs" Duh :/ I'll send an updated series. Justus
Re: how to continue from a breakpoint in GNU/Hurd
On Wed, Jul 17, 2013 at 02:11:58PM +0800, Yue Lu wrote: > When I get the exception message, I set the EIP to the next instruction > (for instance 0x12345678), after resume it, I call get_thread_state(), and > found the EIP is still 0x12345678. The inferior never running anymore. I don't think it has anything to do with the instruction cache. Use the thread_info() call to determine what the suspend count is, it may have been incremented implicitely. -- Richard Braun
[PATCH 4/4] Drop hurd_console_startup.patch
This is no longer necessary with the initscript in place. --- debian/patches/hurd_console_startup.patch | 32 - debian/patches/series |1 - 2 files changed, 33 deletions(-) delete mode 100644 debian/patches/hurd_console_startup.patch diff --git a/debian/patches/hurd_console_startup.patch b/debian/patches/hurd_console_startup.patch deleted file mode 100644 index 8e9301c..000 --- a/debian/patches/hurd_console_startup.patch +++ /dev/null @@ -1,32 +0,0 @@ -Automatically startup the hurd console when enabled. - daemons/runsystem.sh | 14 ++ - 1 file changed, 14 insertions(+) - a/daemons/runsystem.sh -+++ b/daemons/runsystem.sh -@@ -127,10 +127,24 @@ while : ; do - trap "kill -$sig \${runttys_pid}" $sig - done - -+ # Touch the first tty so that the Hurd console is certain to pick it -+ # and not some random other tty. -+ touch /dev/tty1 -+ - # This program reads /etc/ttys and starts the programs it says to. - ${RUNTTYS} & - runttys_pid=$! - -+ # Startup the Hurd console if configured. -+ if [ -e /etc/default/hurd-console ]; then -+unset DISPLAY KBD KBD_REPEAT MOUSE MOUSE_REPEAT SPEAKER -+. /etc/default/hurd-console -+ fi -+ if [ "$ENABLE" = "true" ]; then -+console ${DISPLAY} ${KBD} ${KBD_REPEAT} \ -+${SPEAKER} ${MOUSE} ${MOUSE_REPEAT} -d current_vcs -c /dev/vcs -+ fi -+ - # Wait for runttys to die, meanwhile handling trapped signals. - wait - diff --git a/debian/patches/series b/debian/patches/series index 2e80be7..db75fc6 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -1,7 +1,6 @@ diskfs_no_inherit_dir_group.patch ext2fs_large_stores.patch ext2fs_large_stores_pthread.patch -hurd_console_startup.patch init_try_runsystem.gnu.patch makedev.diff pfinet_dhcp.patch -- 1.7.10.4
[PATCH 2/4] Add (build) dependency on libdaemon
--- debian/control |6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/debian/control b/debian/control index eafb7a6..63b6889 100644 --- a/debian/control +++ b/debian/control @@ -7,7 +7,7 @@ Build-Depends: mig (>= 1.3-2), gnumach-dev (>= 2:1.3.99.dfsg.cvs20070526), libc0.3-dev (>= 2.13-38~), texinfo, texi2html, libncursesw5-dev, debhelper (>= 7.0.50~), gcc-4.7, dpkg (>= 1.15.4) | install-info, autoconf, libparted-dev, libpciaccess-dev, libx11-dev, x11proto-core-dev, pkg-config, - xkb-data, gawk, flex, bison, autotools-dev + xkb-data, gawk, flex, bison, autotools-dev, libdaemon-dev Uploaders: Jeff Bailey , Neal H. Walfield , Michael Banck , Samuel Thibault @@ -27,7 +27,7 @@ Description: GNU Hurd (libraries) Package: hurd Essential: yes Pre-Depends: hurd-libs0.3 -Depends: ${misc:Depends}, hurd-libs0.3 (= ${binary:Version}), sysv-rc, netdde (>= 0.0.20120518~), ${shlibs:Depends}, xkb-data +Depends: ${misc:Depends}, hurd-libs0.3 (= ${binary:Version}), sysv-rc, netdde (>= 0.0.20120518~), ${shlibs:Depends}, xkb-data, libdaemon0 Breaks: gnumach (<< 2:1.3.99.dfsg.cvs20070526-1), libc0.3 (<< 2.11.2-12), netdde (<< 0.0.20121127-2) Suggests: hurd-doc Recommends: bf-utf-source @@ -80,7 +80,7 @@ Package-Type: udeb Priority: optional Section: debian-installer Architecture: hurd-any -Depends: ${misc:Depends}, hurd-libs0.3-udeb (= ${binary:Version}), xkb-data-udeb +Depends: ${misc:Depends}, hurd-libs0.3-udeb (= ${binary:Version}), xkb-data-udeb, libdaemon0 Provides: hurd, ext2-modules, fat-modules, ipv6-modules, isofs-modules, loop-modules, mouse-modules, nfs-modules, socket-modules, ufs-modules Description: GNU Hurd - udeb This is the GNU Hurd udeb package. It contains essential system software and -- 1.7.10.4
[PATCH 1/4] console-client: add daemonizing support
This patch adds daemonizing support using libdaemon. * console-client/console.c (daemonize): New variable. (options): Add --daemonize argument. (parse_opt): Handle --daemonize argument. (daemon_error): New error(3) like macro. (main): Daemonize. --- console-client/Makefile |2 +- console-client/console.c | 104 +++--- 2 files changed, 100 insertions(+), 6 deletions(-) diff --git a/console-client/Makefile b/console-client/Makefile index 69a7e37..0ad7a53 100644 --- a/console-client/Makefile +++ b/console-client/Makefile @@ -37,7 +37,7 @@ SRCS = $(CONSOLE_SRCS) \ VPATH += $(srcdir)/xkb OBJS = $(addsuffix .o,$(basename $(notdir $(SRCS kdioctlServer.o HURDLIBS = cons ports netfs fshelp iohelp ihash shouldbeinlibc -LDLIBS = -ldl -lpthread +LDLIBS = -ldl -lpthread -ldaemon module-dir = $(libdir)/hurd/console console-LDFLAGS = -Wl,-E diff --git a/console-client/console.c b/console-client/console.c index 7c9a880..7dd7a00 100644 --- a/console-client/console.c +++ b/console-client/console.c @@ -26,6 +26,7 @@ #include #include +#include #include #include @@ -61,6 +62,8 @@ static cons_t saved_cons; set. */ static char *console_node; +/* If set, the client will daemonize. */ +static int daemonize; /* Callbacks for input source drivers. */ @@ -516,6 +519,8 @@ cons_vcons_set_mousecursor_status (vcons_t vcons, int status) } +#define DAEMONIZE_KEY 0x80 /* !isascii (DAEMONIZE_KEY), so no short option. */ + /* Console-specific options. */ static const struct argp_option options[] = @@ -524,6 +529,7 @@ options[] = {"driver", 'd', "NAME", 0, "Add driver NAME to the console" }, {"console-node", 'c', "FILE", OPTION_ARG_OPTIONAL, "Set a translator on the node FILE (default: " DEFAULT_CONSOLE_NODE ")" }, +{"daemonize", DAEMONIZE_KEY, NULL, 0, "daemonize the console client"}, {0} }; @@ -577,7 +583,11 @@ parse_opt (int key, char *arg, struct argp_state *state) if (!console_node) return ENOMEM; break; - + +case DAEMONIZE_KEY: + daemonize = 1; + break; + case ARGP_KEY_SUCCESS: if (!devcount) { @@ -598,6 +608,28 @@ static const struct argp_child startup_children[] = static struct argp startup_argp = {options, parse_opt, 0, 0, startup_children}; +#define daemon_error(status, errnum, format, args...) \ + do\ +{ \ + if (daemonize)\ +{ \ + if (errnum) \ +daemon_log (LOG_ERR, format ": %s", ##args, \ +strerror(errnum)); \ + else \ +daemon_log (LOG_ERR, format, ##args); \ + if (status) \ +{ \ + /* Signal parent. */ \ + daemon_retval_send (status); \ + return 0; \ +} \ +} \ + else \ +error (status, errnum, format, ##args); \ +} \ + while (0); + int main (int argc, char *argv[]) { @@ -609,9 +641,67 @@ main (int argc, char *argv[]) /* Parse our command line. This shouldn't ever return an error. */ argp_parse (&startup_argp, argc, argv, ARGP_IN_ORDER, 0, 0); + if (daemonize) +{ + /* Reset signal handlers. */ + if (daemon_reset_sigs (-1) < 0) +error (1, errno, "Failed to reset all signal handlers"); + + /* Unblock signals. */ + if (daemon_unblock_sigs (-1) < 0) +error (1, errno, "Failed to unblock all signals"); + + /* Set indetification string for the daemon for both syslog and + PID file. */ + daemon_pid_file_ident = daemon_log_ident = \ +daemon_ident_from_argv0 (argv[0]); + + /* Check that the daemon is not run twice at the same time. */ + pid_t pid; + if ((pid = daemon_pid_file_is_running ()) >= 0) +error (1, errno, "Daemon already running on PID file %u", pid); + + /* Prepare for return value passing from the initialization + procedure of the daemon process. */ + if (daemon_retval_init () < 0) +
[PATCH 3/4] Add an initscript for the hurd console
--- debian/changelog |1 + debian/hurd.hurd-console.init | 125 + 2 files changed, 126 insertions(+) create mode 100644 debian/hurd.hurd-console.init diff --git a/debian/changelog b/debian/changelog index 81b9e56..adde108 100644 --- a/debian/changelog +++ b/debian/changelog @@ -2,6 +2,7 @@ hurd (20130707-2) UNRELEASED; urgency=low [ Justus Winter ] * Include the umount utility in hurd and hurd-udeb. + * Add an initscript for hurd-console. [ Samuel Thibault ] * Bump Standards-Version to 3.9.4 (no changes). diff --git a/debian/hurd.hurd-console.init b/debian/hurd.hurd-console.init new file mode 100644 index 000..25050fc --- /dev/null +++ b/debian/hurd.hurd-console.init @@ -0,0 +1,125 @@ +#! /bin/sh +### BEGIN INIT INFO +# Provides: hurd-console +# Required-Start:$all +# Required-Stop: +# Default-Start: 1 2 3 4 5 +# Default-Stop: 0 6 +# Short-Description: Example initscript +# Description: This file should be used to construct scripts to be +#placed in /etc/init.d. +### END INIT INFO + +# Author: Justus Winter <4win...@informatik.uni-hamburg.de> + +# PATH should only include /usr/* if it runs after the mountnfs.sh script +PATH=/sbin:/bin +DESC="Hurd console multiplexer" +NAME=console +DAEMON=/bin/$NAME +DAEMON_ARGS="--daemonize -d current_vcs -c /dev/vcs" +PIDFILE=/var/run/$NAME.pid +SCRIPTNAME=/etc/init.d/hurd-$NAME + +# Exit if the package is not installed +[ -x "$DAEMON" ] || exit 0 + +# Read configuration variable file if it is present +[ -r /etc/default/hurd-$NAME ] && . /etc/default/hurd-$NAME + +# Augment the arguments. +DAEMON_ARGS="${DAEMON_ARGS} ${DISPLAY} ${KBD} ${KBD_REPEAT} \ + ${SPEAKER} ${MOUSE} ${MOUSE_REPEAT}" + +# Load the VERBOSE setting and other rcS variables +. /lib/init/vars.sh + +# Define LSB log_* functions. +# Depend on lsb-base (>= 3.2-14) to ensure that this file is present +# and status_of_proc is working. +. /lib/lsb/init-functions + +# +# Function that starts the daemon/service +# +do_start() +{ + # Touch the first tty so that the Hurd console is certain to pick it + # and not some random other tty. + touch /dev/tty1 + + # Return + # 0 if daemon has been started + # 1 if daemon was already running + # 2 if daemon could not be started + start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \ + || return 1 + start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- \ + $DAEMON_ARGS \ + || return 2 +} + +# +# Function that stops the daemon/service +# +do_stop() +{ + # Return + # 0 if daemon has been stopped + # 1 if daemon was already stopped + # 2 if daemon could not be stopped + # other if a failure occurred + start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME + RETVAL="$?" + + [ "$?" = 2 ] && return 2 + # Many daemons don't delete their pidfiles when they exit. + #rm -f $PIDFILE + return "$RETVAL" +} + +case "$1" in + start) + [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "hurd-$NAME" + do_start + case "$?" in + 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; + 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; + esac + ;; + stop) + [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "hurd-$NAME" + do_stop + case "$?" in + 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; + 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; + esac + ;; + status) + status_of_proc "$DAEMON" "hurd-$NAME" && exit 0 || exit $? + ;; + restart|force-reload) + log_daemon_msg "Restarting $DESC" "hurd-$NAME" + do_stop + case "$?" in + 0|1) + do_start + case "$?" in + 0) log_end_msg 0 ;; + 1) log_end_msg 1 ;; # Old process is still running + *) log_end_msg 1 ;; # Failed to start + esac + ;; + *) + # Failed to stop + log_end_msg 1 + ;; + esac + ;; + *) + echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2 + exit 3 + ;; +esac + +: -- 1.7.10.4
Re: how to continue from a breakpoint in GNU/Hurd
Hi. On Wed, Jul 17, 2013 at 8:09 PM, Richard Braun wrote: > On Wed, Jul 17, 2013 at 02:11:58PM +0800, Yue Lu wrote: >> When I get the exception message, I set the EIP to the next instruction >> (for instance 0x12345678), after resume it, I call get_thread_state(), and >> found the EIP is still 0x12345678. The inferior never running anymore. > > I don't think it has anything to do with the instruction cache. Use the > thread_info() call to determine what the suspend count is, it may have > been incremented implicitely. when I used thread_info() to check the suspend count, they are zero. But I met a strange thing. this is my code snippet: thread_basic_info_data_t _info; thread_basic_info_t info = &_info; mach_msg_type_number_t info_len = THREAD_BASIC_INFO_COUNT; error_t err = thread_info (thread->port, THREAD_BASIC_INFO, (int *) &info, &info_len); after this call, the info turn out to be a _NULL_ pointer. I think something maybe wrong, but the err is zero. In thread_takeover_sc_cmd() [gdb/gdb/gnu-nat.c] it has directly access info after thread_info call, so I think this pointer never become a NULL pointer, but in my code, it does. So I think something maybe wrong, or this is a bug in gdb code. -- Yue Lu (陆岳)
Re: how to continue from a breakpoint in GNU/Hurd
On Thu, Jul 18, 2013 at 12:07:20AM +0800, Yue Lu wrote: > when I used thread_info() to check the suspend count, they are zero. > But I met a strange thing. > this is my code snippet: > thread_basic_info_data_t _info; > thread_basic_info_t info = &_info; > mach_msg_type_number_t info_len = THREAD_BASIC_INFO_COUNT; > error_t err = > thread_info (thread->port, THREAD_BASIC_INFO, (int *) &info, &info_len); > > after this call, the info turn out to be a _NULL_ pointer. I think If the info pointer is NULL, how do you determine the suspend count ? > something maybe wrong, but the err is zero. Something does look wrong. Check all the parameters of your call, one by one, rigorously. -- Richard Braun
Re: how to continue from a breakpoint in GNU/Hurd
On Thu, Jul 18, 2013 at 12:13 AM, Richard Braun wrote: > On Thu, Jul 18, 2013 at 12:07:20AM +0800, Yue Lu wrote: >> when I used thread_info() to check the suspend count, they are zero. >> But I met a strange thing. >> this is my code snippet: >> thread_basic_info_data_t _info; >> thread_basic_info_t info = &_info; >> mach_msg_type_number_t info_len = THREAD_BASIC_INFO_COUNT; >> error_t err = >> thread_info (thread->port, THREAD_BASIC_INFO, (int *) &info, &info_len); >> >> after this call, the info turn out to be a _NULL_ pointer. I think > > If the info pointer is NULL, how do you determine the suspend count ? > I used this (&_info)->suspend_count to get the sc value. > Something does look wrong. Check all the parameters of your call, one > by one, rigorously. The only one parameter I used is the first one, I give it as the thread port, something like 119 (I have printf it), the left three parameters are all the same as the code in gnu-nat.c. , -- Yue Lu (陆岳)
Re: [PATCH 4/4] ddb: cleanup db_command.c
Marin Ramesa, le Wed 10 Jul 2013 14:14:29 +0200, a écrit : > Use new .h files in cleanup of db_command.c. Applied, thanks! Samuel