Kills syslog-ng. This function is intended to be used from the state module.

    Users shouldn't use this function, if the service module is available on
    their system.  If :mod:`syslog_ng.set_config_file
    <salt.modules.syslog_ng.set_binary_path>` is called before, this function
    will use the set binary path.

    CLI Example:

    .. code-block:: bash

        salt '*' syslog_ng.stop

def stop(name=None):
    '''
    Kills syslog-ng. This function is intended to be used from the state module.

    Users shouldn't use this function, if the service module is available on
    their system.  If :mod:`syslog_ng.set_config_file
    <salt.modules.syslog_ng.set_binary_path>` is called before, this function
    will use the set binary path.

    CLI Example:

    .. code-block:: bash

        salt '*' syslog_ng.stop

    '''
    pids = __salt__['ps.pgrep'](pattern='syslog-ng')

    if not pids:
        return _format_state_result(name,
                                    result=False,
                                    comment='Syslog-ng is not running')

    if __opts__.get('test', False):
        comment = 'Syslog_ng state module will kill {0} pids'
        return _format_state_result(name, result=None, comment=comment)

    res = __salt__['ps.pkill']('syslog-ng')
    killed_pids = res['killed']

    if killed_pids == pids:
        changes = {'old': killed_pids, 'new': []}
        return _format_state_result(name, result=True, changes=changes)
    else:
        return _format_state_result(name, result=False)