Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7515447
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T00:48:37+00:00 2026-05-30T00:48:37+00:00

In bash when I run a command like wc & or cat & that

  • 0

In bash when I run a command like wc & or cat & that wants standard in right away, it returns immediately with

[1]+ Stopped cat

How is this accomplished? How do I stop a program that I started with exec, and how do I know to stop these programs in the first place? Is there some way to tell that these programs want stdin?

Thanks!

PS also, what is the + about? I’ve always wondered, but that’s really hard to google…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T00:48:39+00:00Added an answer on May 30, 2026 at 12:48 am

    The setpgid() manual page explains how this works:

    A session can have a controlling terminal. At any time, one (and only
    one) of the process groups in the session can be the foreground
    process group for the terminal; the remaining process groups are in
    the background. If a signal is generated from the terminal (e.g.,
    typing the interrupt key to generate SIGINT), that signal is sent to
    the foreground process group. (See termios(3) for a description of
    the characters that generate signals.) Only the foreground process
    group may read(2) from the terminal; if a background process group
    tries to read(2) from the terminal, then the group is sent a
    SIGTSTP signal, which suspends it. The tcgetpgrp(3) and
    tcsetpgrp(3) functions are used to get/set the foreground process
    group of the controlling terminal.

    So what you want to do is this:

    1. When you create a new pipeline, call setpgid() to put all the members of the pipeline in a new process group (with the PID of the first process in the pipeline as the PGID).

    2. Use tcsetpgrp() to manage which process group is in the foreground – if you put a pipeline in the background with &, you should make the shell’s own process group the foreground process group again.

    3. Call waitpid() with the WNOHANG and WUNTRACED flags to check on the status of child processes – this will inform you when they are stopped by SIGTSTP, which will allow you to print a message like bash does.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to run this dreadfully simple command in Bash java -cp nasa-top-secret.jar
I would like to run a sequence of R scripts from the bash command
Hi when I run a command on terminal like that unison dir1 dir2 -ignore
I need to run the command right after the bash starts and then stay
In oracle database, command host can be used to run bash command from database
I've created a few autorun script files on various USB devices that run bash
I'm trying to run a bash script that has: ssh -l <username> <compname> 'sudo
I have a for loop I'd like to run in bash like: for i
I have some ksh scripts which I'd like to convert to run with bash
I have a shell script file (run.sh) that contains the following: #!/bin/bash %JAVA_HOME%/bin/java -jar

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.