microsoft / microsoft/MIEngine

Avoid job control messages when launching GDB

Open
#1,089 0 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
859
Forks
233
Avg merge
1d 6h
Merged PRs (30d)
3

Description

It is my understanding that the following shell script is the cause of microsoft/vscode-cpptools#3298:

https://github.com/microsoft/MIEngine/blob/9470e98d946772ed1ace9ab68e9fbd4d88090b42/src/MICore/UnixUtilities.cs#L49-L63

That is the annoying job control message in the terminal window, for example:

[1] + Done /usr/bin/gdb --interpreter=mi --tty=${DbgTerm} 0</tmp/Microsoft-MIEngine-In-ndptacu6.2ri 1>/tmp/Microsoft-MIEngine-Out-9278nini.hzx

By taking a look at the above script I noticed that GDB is sent to the background just for the sake of fetching its own PID so that it can be written to file. Then the GDB process is waited using wait and in order to do so the shell job control mechanism needs to be enabled.

The unfortunate drawback is the above issue. I'm not fully aware of the internals nor why it is important to save the PID to file but the following provides a way to obtain the same behaviour without the annoying job control message (which is basically what already happens in macOS):

set -o monitor

sleep 3 &
pid=$!
echo "save pid $pid to file..."
fg >/dev/null

The output is:

$ sh test.sh
save 47847 to file...

Moreover, the above comments about Linux vs macOS don't really make sense to me, but anyway this works in both OSs, both sh and bash and both in a shell script and inline:

$ sh -c 'set -o monitor; sleep 3 & pid=$!; echo "save $pid to file..."; fg >/dev/null'
save 47881 to file...

Is this something that are you willing to fix?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with src/MICore/UnixUtilities.cs lines 49-63, where the shell script launches GDB and records its PID. Reproduce the job-control message using the issue's shell examples, then verify that the launch still records and waits for GDB without printing that message on Linux and macOS.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, shell
Domain
devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.