Skip to content

Support fire-and-forget background tasks (for preLaunchTask) #151101

@Trass3r

Description

@Trass3r

My use-case is debugging applications for different platforms via qemu-user.
So far the only way I could make it work is to start qemu-aarch64 -g 1234 ... manually through a task via preLaunchTask and have the gdb launched by the debug extension connect to that gdb-server.

The problem is that qemu -g won't print anything and just blocks indefinitely until gdb connects, so the background problem matcher has a hard time. On top of that I don't really need it to watch for any tasks like background compilation. Just kick off the process.

With just "isBackground": true or with a problem matcher that has "activeOnStart": false it will show a message box after a timeout asking to debug anyway, which works but creates an annoying delay of a couple of seconds on every iteration.
In the past I was somehow able to make it work with

			"isBackground": true,
			"problemMatcher": {
				"base": "$gcc",
				"background": {
					"activeOnStart": true,
					"beginsPattern": ".*",
					"endsPattern": ".*"
				}
			},

But now it doesn't work anymore, I tried different variations with non-matching regexes etc. but it either runs into the timeout or it hangs because the debug extension never gets notified (the only way out is to issue a manual gdb -ex 'target remote :1234' -ex q, after that the debug extension is unblocked and tries to connect to the now destroyed server).

The only workaround I found is to switch the task to a shell type and do some non-obvious magic:

			"type": "shell",
			"command": "nohup /usr/bin/qemu-aarch64 -g 1234 ... & sleep 0.1",

But that will still confusingly stop the program in the beginning due to a Program received signal SIGHUP, Hangup., worked around via setup command handle SIGHUP nostop noprint ignore.

Metadata

Metadata

Assignees

Labels

feature-requestRequest for new features or functionalitytasksTask system issues

Type

No type
No fields configured for issues without a type.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions