<commit_before>/**
 * Created by <NAME>
 * @since  2016.04.29
 * @author <NAME> <<EMAIL>>
 * @link   http://chensoft.com
 */
#include <chen/sys/sys.hpp>
#include <Windows.h>

using namespace chen;

// -----------------------------------------------------------------------------
// proc
std::string proc::path(int argc, const char *const argv[])
{
    CHAR buf[MAX_PATH] = { 0 };

    if (::GetModuleFileName(NULL, buf, sizeof(buf)))
        return std::string(buf);
    else
        return "";
}

int proc::pid()
{
    return ::GetCurrentProcessId();
}

bool proc::kill(int pid)
{
    HANDLE handle = ::OpenProcess(PROCESS_TERMINATE, FALSE, pid);
    BOOL ret = ::TerminateProcess(handle, 0);
    ::CloseHandle(handle);
    return ret == TRUE;
}<commit_msg>proc: check to see if a process exist<commit_after>/**
 * Created by <NAME>
 * @since  2016.04.29
 * @author <NAME> <<EMAIL>>
 * @link   http://chensoft.com
 */
#include <chen/sys/proc.hpp>
#include <Windows.h>

using namespace chen;

// -----------------------------------------------------------------------------
// proc
std::string proc::path(int argc, const char *const argv[])
{
    CHAR buf[MAX_PATH] = { 0 };

    if (::GetModuleFileName(NULL, buf, sizeof(buf)))
        return std::string(buf);
    else
        return "";
}

int proc::pid()
{
    return ::GetCurrentProcessId();
}

bool proc::kill(int pid)
{
    HANDLE handle = ::OpenProcess(PROCESS_TERMINATE, FALSE, pid);
    if (handle == INVALID_HANDLE_VALUE)
        return false;

    BOOL ret = ::TerminateProcess(handle, 0);

    ::CloseHandle(handle);
    return ret == TRUE;
}

bool proc::exist(int pid)
{
    HANDLE handle = ::OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, pid);
    if (handle == INVALID_HANDLE_VALUE)
        return false;

    DWORD status = 0;
    ::GetExitCodeProcess(handle, &status);

    ::CloseHandle(handle);
    return status == STILL_ACTIVE;
}
{'fraction_non_alphanumeric': 0.22935297211993688, 'fraction_numerical': 0.011046817464492372, 'mean_word_length': 2.4519056261343013, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7525959', 'n_tokens_mistral': 620, 'n_tokens_neox': 587, 'n_words': 148}