当前位置: 首页>>代码示例>>C++>>正文


C++ parser_t::jobs方法代码示例

本文整理汇总了C++中parser_t::jobs方法的典型用法代码示例。如果您正苦于以下问题:C++ parser_t::jobs方法的具体用法?C++ parser_t::jobs怎么用?C++ parser_t::jobs使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在parser_t的用法示例。


在下文中一共展示了parser_t::jobs方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: find_job_by_name

/// It should search the job list for something matching the given proc.
static bool find_job_by_name(const wchar_t *proc, std::vector<job_id_t> &ids,
                             const parser_t &parser) {
    bool found = false;

    for (const auto &j : parser.jobs()) {
        if (j->command_is_empty()) continue;

        if (match_pid(j->command(), proc)) {
            if (!contains(ids, j->job_id)) {
                // If pids doesn't already have the pgid, add it.
                ids.push_back(j->job_id);
            }
            found = true;
        }

        // Check if the specified pid is a child process of the job.
        for (const process_ptr_t &p : j->processes) {
            if (p->actual_cmd.empty()) continue;

            if (match_pid(p->actual_cmd, proc)) {
                if (!contains(ids, j->job_id)) {
                    // If pids doesn't already have the pgid, add it.
                    ids.push_back(j->job_id);
                }
                found = true;
            }
        }
    }

    return found;
}
开发者ID:fish-shell,项目名称:fish-shell,代码行数:32,代码来源:builtin_wait.cpp

示例2: all_jobs_finished

static bool all_jobs_finished(const parser_t &parser) {
    for (const auto &j : parser.jobs()) {
        // If any job is not completed, return false.
        // If there are stopped jobs, they are ignored.
        if (j->is_constructed() && !j->is_completed() && !j->is_stopped()) {
            return false;
        }
    }
    return true;
}
开发者ID:fish-shell,项目名称:fish-shell,代码行数:10,代码来源:builtin_wait.cpp

示例3: wait_for_backgrounds

static int wait_for_backgrounds(parser_t &parser, bool any_flag) {
    size_t jobs_len = parser.jobs().size();

    while ((!any_flag && !all_jobs_finished(parser)) ||
           (any_flag && !any_jobs_finished(jobs_len, parser))) {
        if (reader_test_interrupted()) {
            return 128 + SIGINT;
        }
        proc_wait_any(parser);
    }
    return 0;
}
开发者ID:fish-shell,项目名称:fish-shell,代码行数:12,代码来源:builtin_wait.cpp

示例4: any_jobs_finished

static bool any_jobs_finished(size_t jobs_len, const parser_t &parser) {
    bool no_jobs_running = true;

    // If any job is removed from list, return true.
    if (jobs_len != parser.jobs().size()) {
        return true;
    }
    for (const auto &j : parser.jobs()) {
        // If any job is completed, return true.
        if (j->is_constructed() && (j->is_completed() || j->is_stopped())) {
            return true;
        }
        // Check for jobs running exist or not.
        if (j->is_constructed() && !j->is_stopped()) {
            no_jobs_running = false;
        }
    }
    if (no_jobs_running) {
        return true;
    }
    return false;
}
开发者ID:fish-shell,项目名称:fish-shell,代码行数:22,代码来源:builtin_wait.cpp

示例5: get_job_id_from_pid

/// Return the job id to which the process with pid belongs.
/// If a specified process has already finished but the job hasn't, parser_t::job_get_from_pid()
/// doesn't work properly, so use this function in wait command.
static job_id_t get_job_id_from_pid(pid_t pid, const parser_t &parser) {
    for (const auto &j : parser.jobs()) {
        if (j->pgid == pid) {
            return j->job_id;
        }
        // Check if the specified pid is a child process of the job.
        for (const process_ptr_t &p : j->processes) {
            if (p->pid == pid) {
                return j->job_id;
            }
        }
    }
    return 0;
}
开发者ID:fish-shell,项目名称:fish-shell,代码行数:17,代码来源:builtin_wait.cpp


注:本文中的parser_t::jobs方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。