最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

visual studio code - VSCode tasks that automatically kills all other tasks on invoke - Stack Overflow

matteradmin6PV0评论

When using vs.code, I have to use a non-standard compiler, and it's easier to just run it from Makefile. I have it set up as a task in tasks.json. I am trying to make my postDebugTask remain in terminal if there is an error. I am trying to do that with my postDebugTask called run_flash.

BUT, if I re-invoke the build or "run" process, I want to terminate all running tasks. I am trying to do this with my preLaunchTask kill_all_tasks.

If I launch another process, it does not kill the previous process.

Really, what I want is for any time my normal task is launched, I want to kill off the previous task. Like is there any sort of task option to say "there can only be one of these tasks"?

Here is the launch configuration from my launch.json

        {
            "name": "Compile and Flash",
            "type": "node",
            "request": "launch",
            "internalConsoleOptions": "neverOpen",
            "preLaunchTask" : "kill_all_tasks",
            "postDebugTask": "run_flash",
            "presentation": {
                "hidden": false,
                "group": "terminaloutput",
                "order": 1
            },
            "runtimeExecutable": "echo"
        }

Here are my tasks:

        {
            "type": "shell",
            "label": "run_flash",
            "command": "make clean closechlink; make flash",
            "presentation": {
                "echo": true,
                "focus": true,
                "group": "build",
                "panel": "shared",
                "close": true,
                "reveal": "always",
                "showReuseMessage": true
            },
            "isBackground": false,
            "options": {
                "cwd": "${workspaceFolder}",
            },
            "runOptions": {
                "instanceLimit": 1,
            },
            "group": "build",
            "problemMatcher": { // 
                "owner": "cpp",
                "fileLocation": [
                    "relative",
                    "${workspaceFolder}"
                ],
                "pattern": {
                    "regexp": "^(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$",
                    "file": 1,
                    "line": 2,
                    "column": 3,
                    "severity": 4,
                    "message": 5
                },
            }
        },
        {
            "type": "process",
            "label" : "kill_all_tasks",
            "command":[
                "${command:workbench.action.tasks.terminate}  terminateAll",
            ]
        }
Post a comment

comment list (0)

  1. No comments so far