Deleted Added
full compact
hooks.c (213183) hooks.c (213429)
1/*-
2 * Copyright (c) 2010 The FreeBSD Foundation
3 * Copyright (c) 2010 Pawel Jakub Dawidek <pjd@FreeBSD.org>
4 * All rights reserved.
5 *
6 * This software was developed by Pawel Jakub Dawidek under sponsorship from
7 * the FreeBSD Foundation.
8 *

--- 15 unchanged lines hidden (view full) ---

24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 * SUCH DAMAGE.
29 */
30
31#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2010 The FreeBSD Foundation
3 * Copyright (c) 2010 Pawel Jakub Dawidek <pjd@FreeBSD.org>
4 * All rights reserved.
5 *
6 * This software was developed by Pawel Jakub Dawidek under sponsorship from
7 * the FreeBSD Foundation.
8 *

--- 15 unchanged lines hidden (view full) ---

24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 * SUCH DAMAGE.
29 */
30
31#include <sys/cdefs.h>
32__FBSDID("$FreeBSD: head/sbin/hastd/hooks.c 213183 2010-09-26 10:39:01Z pjd $");
32__FBSDID("$FreeBSD: head/sbin/hastd/hooks.c 213429 2010-10-04 21:43:06Z pjd $");
33
34#include <sys/types.h>
35#include <sys/sysctl.h>
36#include <sys/wait.h>
37
38#include <assert.h>
39#include <errno.h>
40#include <fcntl.h>

--- 247 unchanged lines hidden (view full) ---

288 pjdlog_error("Hook exited ungracefully (pid=%u, exitcode=%d, cmd=[%s]).",
289 pid, WIFEXITED(status) ? WEXITSTATUS(status) : -1,
290 hp->hp_comm);
291 }
292 hook_free(hp);
293}
294
295void
33
34#include <sys/types.h>
35#include <sys/sysctl.h>
36#include <sys/wait.h>
37
38#include <assert.h>
39#include <errno.h>
40#include <fcntl.h>

--- 247 unchanged lines hidden (view full) ---

288 pjdlog_error("Hook exited ungracefully (pid=%u, exitcode=%d, cmd=[%s]).",
289 pid, WIFEXITED(status) ? WEXITSTATUS(status) : -1,
290 hp->hp_comm);
291 }
292 hook_free(hp);
293}
294
295void
296hook_check(bool sigchld)
296hook_check(void)
297{
298 struct hookproc *hp, *hp2;
297{
298 struct hookproc *hp, *hp2;
299 int status;
300 time_t now;
299 time_t now;
301 pid_t pid;
302
303 assert(hooks_initialized);
304
305 /*
300
301 assert(hooks_initialized);
302
303 /*
306 * If SIGCHLD was received, garbage collect finished processes.
307 */
308 if (sigchld) {
309 while ((pid = wait3(&status, WNOHANG, NULL)) > 0)
310 hook_check_one(pid, status);
311 }
312
313 /*
314 * Report about processes that are running for a long time.
315 */
316 now = time(NULL);
317 mtx_lock(&hookprocs_lock);
318 TAILQ_FOREACH_SAFE(hp, &hookprocs, hp_next, hp2) {
319 assert(hp->hp_magic == HOOKPROC_MAGIC_ONLIST);
320 assert(hp->hp_pid > 0);
321

--- 81 unchanged lines hidden ---
304 * Report about processes that are running for a long time.
305 */
306 now = time(NULL);
307 mtx_lock(&hookprocs_lock);
308 TAILQ_FOREACH_SAFE(hp, &hookprocs, hp_next, hp2) {
309 assert(hp->hp_magic == HOOKPROC_MAGIC_ONLIST);
310 assert(hp->hp_pid > 0);
311

--- 81 unchanged lines hidden ---