summaryrefslogtreecommitdiff
path: root/tests/sentinel/tests/includes/notify.sh
blob: 5de0eaf76fe2263108d38ff9d0d408e575d9bf85 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/usr/bin/env bash

OS=`uname -s`
if [ ${OS} != "Linux" ]
then
    exit 0
fi

# fd 3 is meant to catch the actual access to /proc/pid/fd, 
# in case there's an fd leak by the sentinel,
# it can take 3, but then the access to /proc will take another fd, and we'll catch that.
leaked_fd_count=`ls /proc/self/fd | grep -vE '^[0|1|2|3]$' | wc -l`
if [ $leaked_fd_count -gt 0 ]
then
    sentinel_fd_leaks_file="../sentinel_fd_leaks"
    if [ ! -f $sentinel_fd_leaks_file ]
    then
        ls -l /proc/self/fd | cat >> $sentinel_fd_leaks_file
        lsof -p $$ | cat >> $sentinel_fd_leaks_file
    fi
fi