Repository: apple/swift-nio
File: IntegrationTests/tests_01_http/defines.sh (Shell)

Code before:
    echo "local token_open_fds" >> "$token"
    echo "token_open_fds='$(get_number_of_open_fds_for_pid "$tmp_server_pid")'" >> "$token"
    local curl_host=${maybe_host:-localhost}
    do_curl "$token" "http://$curl_host:$curl_port/dynamic/pid"
}

function get_htdocs() {
    source "$1"
    echo "$token_htdocs"
}

function get_socket() {
    source "$1"
    echo "$token_port"
}

function stop_server() {
    source "$1"
    sleep 0.5 # just to make sure all the fds could be closed
    if command -v lsof > /dev/null 2> /dev/null; then
        do_netstat "$token_type"
        assert_number_of_open_fds_for_pid_equals "$token_pid" "$token_open_fds"
    fi
    kill -0 "$token_pid" # assert server is still running ignore-unacceptable-language
    ###kill -INT "$token_pid" # tell server to shut down gracefully ignore-unacceptable-language
    kill "$token_pid" # tell server to shut down gracefully ignore-unacceptable-language
    for f in $(seq 20); do
        if ! kill -0 "$token_pid" 2> /dev/null; then # ignore-unacceptable-language
            break # good, dead
        fi
        ps auxw | grep "$token_pid" || true
        sleep 0.1
    done
    if kill -0 "$token_pid" 2> /dev/null; then # ignore-unacceptable-language
        fail "server $token_pid still running"
    fi
}

function get_server_pid() {
    source "$1"
    echo "$token_pid"
}

function get_server_port() {
    source "$1"
    echo "$token_port"
}

function get_server_ip() {
    source "$1"
    echo "$token_server_ip"

Review comment (suggestion):
rather than blatting 'ignore-unacceptable-language' onto the end of each line can we promote the actual comments to the line above, e.g.

```
# assert server is still running
kill -0 "$token_pid" # ignore-unacceptable-language 
```

Code after:
    echo "local token_open_fds" >> "$token"
    echo "token_open_fds='$(get_number_of_open_fds_for_pid "$tmp_server_pid")'" >> "$token"
    local curl_host=${maybe_host:-localhost}
    do_curl "$token" "http://$curl_host:$curl_port/dynamic/pid"
}

function get_htdocs() {
    source "$1"
    echo "$token_htdocs"
}

function get_socket() {
    source "$1"
    echo "$token_port"
}

function stop_server() {
    source "$1"
    sleep 0.5 # just to make sure all the fds could be closed
    if command -v lsof > /dev/null 2> /dev/null; then
        do_netstat "$token_type"
        assert_number_of_open_fds_for_pid_equals "$token_pid" "$token_open_fds"
    fi
    # assert server is still running
    kill -0 "$token_pid" # ignore-unacceptable-language
    # tell server to shut down gracefully
    kill "$token_pid" # ignore-unacceptable-language
    for f in $(seq 20); do
        if ! kill -0 "$token_pid" 2> /dev/null; then # ignore-unacceptable-language
            break # good, dead
        fi
        ps auxw | grep "$token_pid" || true
        sleep 0.1
    done
    if kill -0 "$token_pid" 2> /dev/null; then # ignore-unacceptable-language
        fail "server $token_pid still running"
    fi
}

function get_server_pid() {
    source "$1"
    echo "$token_pid"
}

function get_server_port() {
    source "$1"
    echo "$token_port"
}

function get_server_ip() {
    source "$1"