def _kill_app(self, method, process_count):
        """ Confirms that a number of test apps are terminated after the
            provided method is executed.

            `method`
                Callable to execute when testing app terminate functionality.
                This method will be passed the filename for the test app binary
                that will be launched to test against.
            `process_count`
                Number of test apps to launch that are supposed to be killed.

            Returns ``True`` if all launched apps were successfully terminated.
            """

        # range check
        if process_count > 20:
            process_count = 20
        if process_count < 1:
            process_count = 1

        # make a copy of 'sh' shell binary and alter it so it has a unique
        # checksum for this binary, so we don't kill other running instances of
        # bin/sh
        bin_file = self.make_file()
        shutil.copyfile('/bin/sh', bin_file)

        # change the checksum of the binary
        open(bin_file, 'a+b', 0).write('A' * 100)
        os.chmod(bin_file, 0700)  # set exec.. silly macosx

        # launch copied shell binary in background
        processes = {}
        for i in range(process_count):
            proc = subprocess.Popen([bin_file, '-c',
                                     'while true; do sleep 1; done'],
                                    stdout=subprocess.PIPE,
                                    stderr=subprocess.PIPE,
                                    stdin=subprocess.PIPE)
            processes[proc.pid] = proc

        # call provided method
        method(bin_file)

        i = 0
        while i < 1500:
            i += 1

            try:
                # wait for the processes to die; reclaim process entries
                pid, status = os.waitpid(-1, os.P_NOWAIT)
                time.sleep(0.05)
            except __HOLE__:
                break

            if pid in processes:
                del processes[pid]

        fail = False
        if processes:
            fail = True

            # kill what's leftover
            for pid, proc in processes.iteritems():
                try:
                    proc.terminate()
                    proc.wait()
                except OSError:
                    pass

        return (not fail)
dataset/ETHPy150Open xtrementl/focus/tests/unit/plugin/modules/test_apps.py/CloseAppCase._kill_app