support SIGINFO

This commit is contained in:
christos 2018-08-21 15:37:33 +00:00
parent 1834dc7936
commit 70aed070fa
2 changed files with 37 additions and 2 deletions

View File

@ -17,7 +17,7 @@
*
*/
#include <sys/cdefs.h>
__RCSID("$NetBSD: main.c,v 1.6 2016/05/17 14:00:09 christos Exp $");
__RCSID("$NetBSD: main.c,v 1.7 2018/08/21 15:37:33 christos Exp $");
#include "cvs.h"
@ -498,6 +498,32 @@ divide_by (unsigned char buf[COMMITID_RAW_SIZE], unsigned int d)
return carry;
}
#ifdef SIGINFO
#include <paths.h>
static void
show_status (int n)
{
char wd[PATH_MAX];
char buf[2048];
static int ttyfd = -2;
if (ttyfd == -2)
ttyfd = open(_PATH_TTY, O_RDWR, O_CLOEXEC);
if (ttyfd == -1)
return;
if (getcwd(wd, sizeof(wd)) == NULL)
return;
n = snprintf(buf, sizeof(buf), "%s[%d]: working in %s\n", getprogname(),
(int)getpid(), wd);
if (n <= 0)
return;
write(ttyfd, buf, (size_t)n);
}
#endif
static void
convert (char const input[COMMITID_RAW_SIZE], char *output)
{
@ -967,6 +993,9 @@ cause intermittent sandbox corruption.");
/* make sure we clean up on error */
signals_register (main_cleanup);
#ifdef SIGINFO
signal (SIGINFO, show_status);
#endif
#ifdef KLUDGE_FOR_WNT_TESTSUITE
/* Probably the need for this will go away at some point once

View File

@ -12,7 +12,7 @@
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. */
#include <sys/cdefs.h>
__RCSID("$NetBSD: run.c,v 1.3 2016/05/17 14:00:09 christos Exp $");
__RCSID("$NetBSD: run.c,v 1.4 2018/08/21 15:37:33 christos Exp $");
#include "cvs.h"
@ -239,6 +239,9 @@ run_exec (const char *stin, const char *stout, const char *sterr, int flags)
#endif
if (pid == 0)
{
#ifdef SIGINFO
signal (SIGINFO, SIG_DFL);
#endif
#ifdef SETXID_SUPPORT
if (flags & RUN_UNSETXID) {
(void) setgid (getgid ());
@ -570,6 +573,9 @@ piped_child (char *const *command, int *tofdp, int *fromfdp, bool fix_stderr)
error (1, errno, "cannot fork");
if (pid == 0)
{
#ifdef SIGINFO
signal (SIGINFO, SIG_DFL);
#endif
if (dup2 (to_child_pipe[0], STDIN_FILENO) < 0)
error (1, errno, "cannot dup2 pipe");
if (close (to_child_pipe[1]) < 0)