332 .pop_psinfo = Ppsinfo_live,
333 .pop_lstatus = Plstatus_live,
334 .pop_lpsinfo = Plpsinfo_live,
335 .pop_platform = Pplatform_live,
336 .pop_uname = Puname_live,
337 .pop_zonename = Pzonename_live,
338 .pop_execname = Pexecname_live,
339 .pop_secflags = Psecflags_live,
340 #if defined(__i386) || defined(__amd64)
341 .pop_ldt = Pldt_live
342 #endif
343 };
344
345 /*
346 * This is the library's .init handler.
347 */
348 #pragma init(_libproc_init)
349 void
350 _libproc_init(void)
351 {
352 _libproc_debug = getenv("LIBPROC_DEBUG") != NULL;
353 _libproc_no_qsort = getenv("LIBPROC_NO_QSORT") != NULL;
354 _libproc_incore_elf = getenv("LIBPROC_INCORE_ELF") != NULL;
355
356 (void) sigfillset(&blockable_sigs);
357 (void) sigdelset(&blockable_sigs, SIGKILL);
358 (void) sigdelset(&blockable_sigs, SIGSTOP);
359 }
360
361 void
362 Pset_procfs_path(const char *path)
363 {
364 (void) snprintf(procfs_path, sizeof (procfs_path), "%s", path);
365 }
366
367 /*
368 * Call set_minfd() once before calling dupfd() several times.
369 * We assume that the application will not reduce its current file
370 * descriptor limit lower than 512 once it has set at least that value.
371 */
372 int
373 set_minfd(void)
374 {
375 static mutex_t minfd_lock = DEFAULTMUTEX;
1781 break;
1782 case PR_FAULTED:
1783 dprintf("%s: FAULTED %s\n", caller,
1784 proc_fltname(lsp->pr_what, name, sizeof (name)));
1785 break;
1786 case PR_SYSENTRY:
1787 dprintf("%s: SYSENTRY %s\n", caller,
1788 proc_sysname(lsp->pr_what, name, sizeof (name)));
1789 break;
1790 case PR_SYSEXIT:
1791 dprintf("%s: SYSEXIT %s\n", caller,
1792 proc_sysname(lsp->pr_what, name, sizeof (name)));
1793 break;
1794 case PR_JOBCONTROL:
1795 dprintf("%s: JOBCONTROL %s\n", caller,
1796 proc_signame(lsp->pr_what, name, sizeof (name)));
1797 break;
1798 case PR_SUSPENDED:
1799 dprintf("%s: SUSPENDED\n", caller);
1800 break;
1801 default:
1802 dprintf("%s: Unknown\n", caller);
1803 break;
1804 }
1805
1806 if (lsp->pr_cursig)
1807 dprintf("%s: p_cursig = %d\n", caller, lsp->pr_cursig);
1808
1809 bits = *((uint32_t *)&lsp->pr_lwppend);
1810 if (bits)
1811 dprintf("%s: pr_lwppend = 0x%.8X\n", caller, bits);
1812 }
1813
1814 /* debugging */
1815 static void
1816 prdump(struct ps_prochandle *P)
1817 {
1818 uint32_t bits;
1819
1820 prldump("Pstopstatus", &P->status.pr_lwp);
1960 /*
1961 * If the process was already stopped coming into Pstopstatus(),
1962 * then don't use its PC to set P->sysaddr since it may have been
1963 * changed since the time the process originally stopped.
1964 */
1965 if (old_state == PS_STOP)
1966 return (0);
1967
1968 switch (P->status.pr_lwp.pr_why) {
1969 case PR_SYSENTRY:
1970 case PR_SYSEXIT:
1971 if (Pissyscall_prev(P, P->status.pr_lwp.pr_reg[R_PC],
1972 &P->sysaddr) == 0)
1973 P->sysaddr = P->status.pr_lwp.pr_reg[R_PC];
1974 break;
1975 case PR_REQUESTED:
1976 case PR_SIGNALLED:
1977 case PR_FAULTED:
1978 case PR_JOBCONTROL:
1979 case PR_SUSPENDED:
1980 break;
1981 default:
1982 errno = EPROTO;
1983 return (-1);
1984 }
1985
1986 return (0);
1987 }
1988
1989 /*
1990 * Wait for the process to stop for any reason.
1991 */
1992 int
1993 Pwait(struct ps_prochandle *P, uint_t msec)
1994 {
1995 return (Pstopstatus(P, PCWSTOP, msec));
1996 }
1997
1998 /*
1999 * Direct the process to stop; wait for it to stop.
3548 if (request == PCNULL || request == PCDSTOP || msec != 0)
3549 return (0);
3550 dprintf("Lstopstatus: LWP is not stopped\n");
3551 errno = EPROTO;
3552 return (-1);
3553 }
3554
3555 L->lwp_state = PS_STOP;
3556
3557 if (_libproc_debug) /* debugging */
3558 prldump("Lstopstatus", &L->lwp_status);
3559
3560 switch (L->lwp_status.pr_why) {
3561 case PR_SYSENTRY:
3562 case PR_SYSEXIT:
3563 case PR_REQUESTED:
3564 case PR_SIGNALLED:
3565 case PR_FAULTED:
3566 case PR_JOBCONTROL:
3567 case PR_SUSPENDED:
3568 break;
3569 default:
3570 errno = EPROTO;
3571 return (-1);
3572 }
3573
3574 return (0);
3575 }
3576
3577 /*
3578 * Wait for the LWP to stop for any reason.
3579 */
3580 int
3581 Lwait(struct ps_lwphandle *L, uint_t msec)
3582 {
3583 return (Lstopstatus(L, PCWSTOP, msec));
3584 }
3585
3586 /*
3587 * Direct the LWP to stop; wait for it to stop.
|
332 .pop_psinfo = Ppsinfo_live,
333 .pop_lstatus = Plstatus_live,
334 .pop_lpsinfo = Plpsinfo_live,
335 .pop_platform = Pplatform_live,
336 .pop_uname = Puname_live,
337 .pop_zonename = Pzonename_live,
338 .pop_execname = Pexecname_live,
339 .pop_secflags = Psecflags_live,
340 #if defined(__i386) || defined(__amd64)
341 .pop_ldt = Pldt_live
342 #endif
343 };
344
345 /*
346 * This is the library's .init handler.
347 */
348 #pragma init(_libproc_init)
349 void
350 _libproc_init(void)
351 {
352 const char *root;
353
354 _libproc_debug = getenv("LIBPROC_DEBUG") != NULL;
355 _libproc_no_qsort = getenv("LIBPROC_NO_QSORT") != NULL;
356 _libproc_incore_elf = getenv("LIBPROC_INCORE_ELF") != NULL;
357
358 if ((root = zone_get_nroot()) != NULL)
359 (void) snprintf(procfs_path, sizeof (procfs_path), "%s/proc",
360 root);
361
362 (void) sigfillset(&blockable_sigs);
363 (void) sigdelset(&blockable_sigs, SIGKILL);
364 (void) sigdelset(&blockable_sigs, SIGSTOP);
365 }
366
367 void
368 Pset_procfs_path(const char *path)
369 {
370 (void) snprintf(procfs_path, sizeof (procfs_path), "%s", path);
371 }
372
373 /*
374 * Call set_minfd() once before calling dupfd() several times.
375 * We assume that the application will not reduce its current file
376 * descriptor limit lower than 512 once it has set at least that value.
377 */
378 int
379 set_minfd(void)
380 {
381 static mutex_t minfd_lock = DEFAULTMUTEX;
1787 break;
1788 case PR_FAULTED:
1789 dprintf("%s: FAULTED %s\n", caller,
1790 proc_fltname(lsp->pr_what, name, sizeof (name)));
1791 break;
1792 case PR_SYSENTRY:
1793 dprintf("%s: SYSENTRY %s\n", caller,
1794 proc_sysname(lsp->pr_what, name, sizeof (name)));
1795 break;
1796 case PR_SYSEXIT:
1797 dprintf("%s: SYSEXIT %s\n", caller,
1798 proc_sysname(lsp->pr_what, name, sizeof (name)));
1799 break;
1800 case PR_JOBCONTROL:
1801 dprintf("%s: JOBCONTROL %s\n", caller,
1802 proc_signame(lsp->pr_what, name, sizeof (name)));
1803 break;
1804 case PR_SUSPENDED:
1805 dprintf("%s: SUSPENDED\n", caller);
1806 break;
1807 case PR_BRAND:
1808 dprintf("%s: BRANDPRIVATE (%d)\n", caller, lsp->pr_what);
1809 break;
1810 default:
1811 dprintf("%s: Unknown\n", caller);
1812 break;
1813 }
1814
1815 if (lsp->pr_cursig)
1816 dprintf("%s: p_cursig = %d\n", caller, lsp->pr_cursig);
1817
1818 bits = *((uint32_t *)&lsp->pr_lwppend);
1819 if (bits)
1820 dprintf("%s: pr_lwppend = 0x%.8X\n", caller, bits);
1821 }
1822
1823 /* debugging */
1824 static void
1825 prdump(struct ps_prochandle *P)
1826 {
1827 uint32_t bits;
1828
1829 prldump("Pstopstatus", &P->status.pr_lwp);
1969 /*
1970 * If the process was already stopped coming into Pstopstatus(),
1971 * then don't use its PC to set P->sysaddr since it may have been
1972 * changed since the time the process originally stopped.
1973 */
1974 if (old_state == PS_STOP)
1975 return (0);
1976
1977 switch (P->status.pr_lwp.pr_why) {
1978 case PR_SYSENTRY:
1979 case PR_SYSEXIT:
1980 if (Pissyscall_prev(P, P->status.pr_lwp.pr_reg[R_PC],
1981 &P->sysaddr) == 0)
1982 P->sysaddr = P->status.pr_lwp.pr_reg[R_PC];
1983 break;
1984 case PR_REQUESTED:
1985 case PR_SIGNALLED:
1986 case PR_FAULTED:
1987 case PR_JOBCONTROL:
1988 case PR_SUSPENDED:
1989 case PR_BRAND:
1990 break;
1991 default:
1992 errno = EPROTO;
1993 return (-1);
1994 }
1995
1996 return (0);
1997 }
1998
1999 /*
2000 * Wait for the process to stop for any reason.
2001 */
2002 int
2003 Pwait(struct ps_prochandle *P, uint_t msec)
2004 {
2005 return (Pstopstatus(P, PCWSTOP, msec));
2006 }
2007
2008 /*
2009 * Direct the process to stop; wait for it to stop.
3558 if (request == PCNULL || request == PCDSTOP || msec != 0)
3559 return (0);
3560 dprintf("Lstopstatus: LWP is not stopped\n");
3561 errno = EPROTO;
3562 return (-1);
3563 }
3564
3565 L->lwp_state = PS_STOP;
3566
3567 if (_libproc_debug) /* debugging */
3568 prldump("Lstopstatus", &L->lwp_status);
3569
3570 switch (L->lwp_status.pr_why) {
3571 case PR_SYSENTRY:
3572 case PR_SYSEXIT:
3573 case PR_REQUESTED:
3574 case PR_SIGNALLED:
3575 case PR_FAULTED:
3576 case PR_JOBCONTROL:
3577 case PR_SUSPENDED:
3578 case PR_BRAND:
3579 break;
3580 default:
3581 errno = EPROTO;
3582 return (-1);
3583 }
3584
3585 return (0);
3586 }
3587
3588 /*
3589 * Wait for the LWP to stop for any reason.
3590 */
3591 int
3592 Lwait(struct ps_lwphandle *L, uint_t msec)
3593 {
3594 return (Lstopstatus(L, PCWSTOP, msec));
3595 }
3596
3597 /*
3598 * Direct the LWP to stop; wait for it to stop.
|