用于注册后台进程的 UNIX 系统调用 [英] UNIX System call to register a background process

查看:27
本文介绍了用于注册后台进程的 UNIX 系统调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写自己的 shell 作为课程作业的一部分.所以我需要支持后台工作.我正在维护作业 ID 和后台作业的数据结构.但是我还需要告诉内核这是一个后台进程,这样就只有一个终端前台进程.到目前为止,我在我的程序级别处理后台工作.

I am writing my own shell as part of course assignment. So I need to support background jobs. I am maintaining data strutures for job id and background jobs. But I need to also tell the kernel that this is a background process, so that there is only one terminal foreground process. Until now I am handling background jobs at my program level.

注册后台进程的函数调用是什么?

What is the function call to register a background process?

推荐答案

如果你想让一个进程成为终端控制组的一部分,最简单的方法就是简单地给它一个不同的组.

If you want a process to not be part of the terminal's controlling group, the simplest method is to simply give it a different group.

switch (fork()) {
    case 0:
        setpgid(getpid(), getpid());
        execvp(...);

这篇关于用于注册后台进程的 UNIX 系统调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆