Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OpenProcess: The parameter is incorrect. #17

Closed
danawoodman opened this issue Dec 17, 2019 · 4 comments
Closed

OpenProcess: The parameter is incorrect. #17

danawoodman opened this issue Dec 17, 2019 · 4 comments

Comments

@danawoodman
Copy link
Contributor

danawoodman commented Dec 17, 2019

I am getting the error OpenProcess: The parameter is incorrect. when trying to run overseer.Stop(id) on a process running on a Windows VM.

Any ideas why this might be the case? I'm unable to stop processes running on Windows machines including using the example program.

Here is the full reproducible test code:

package main

import (
	"fmt"
	"os"
	"time"

	cmd "github.com/ShinyTrinkets/overseer"
)

func main() {
	ovr := cmd.NewOverseer()

	// Disable output buffering, enable streaming
	cmdOptions := cmd.Options{
		Buffered:   false,
		Streaming:  true,
		DelayStart: 1,
		RetryTimes: 9999999,
	}

	// Add Cmd with options
	id1 := "ping1"
	pingCmd := ovr.Add(id1, "ping", []string{"-t", "localhost"}, cmdOptions)
	pingCmd.Start()

	statusFeed := make(chan *cmd.ProcessJSON)
	ovr.Watch(statusFeed)

	// Capture status updates from the command
	go func() {
		for state := range statusFeed {
			fmt.Printf("STATE: %v\n", state)
		}
	}()

	// Capture STDOUT and STDERR lines streaming from Cmd
	// If you don't capture them, they will be written into
	// the overseer log to Info or Error.
	go func() {
		ticker := time.NewTicker(100 * time.Millisecond)
		for {
			select {
			case line := <-pingCmd.Stdout:
				fmt.Println(line)
			case line := <-pingCmd.Stderr:
				fmt.Fprintln(os.Stderr, line)
			case <-ticker.C:
				if !ovr.IsRunning() {
					fmt.Println("Closing Stdout and Stderr loop")
				}
			}
		}
	}()

	go func() {
		time.Sleep(5 * time.Second)
		fmt.Println("stopping!")
		err := ovr.Stop(id1)
		if err != nil {
			panic(err)
		}
	}()

	// Run and wait for all commands to finish
	ovr.SuperviseAll()

	// Even after the command is finished, you can still access detailed info
	time.Sleep(100 * time.Millisecond)
	fmt.Println(ovr.Status(id1))
}

Should just be able to run the built program on a Windows machine and after 5 seconds the panic will trigger.

Here are some links with info:

@croqaz
Copy link
Member

croqaz commented Dec 23, 2019

Hi !
Thanks for rasining this issue. I can't reproduce it because I have no Windows computer anywhere near. And I don't plan on supporting Windows for Overseer.
You're probably right that some functions behave differently on Windows vs Other.
If you find a portable way to fix this, I'll gladly review your PR. Let me know.

@navono
Copy link

navono commented Dec 27, 2019

The whole Cmd implemented in overseer is based on Linux, doesn't match Windows. So, even correction the pid that pass to os.FindProcess, the proc.Signal also cause another error. Simply put, overseer not all features support Windows. Perhaps having this documented in the README might dispel some doubts.

navono pushed a commit to navono/overseer that referenced this issue Dec 27, 2019
implement Stop signal across platforms
@croqaz
Copy link
Member

croqaz commented Dec 27, 2019

Thank you for the PR @navono !
Also you're right I should have mentioned about the Windows support, I'll mention in the README.
I'll check your code later this weekend, I hope :) But the tests are passing, so that's a good sign!

@croqaz
Copy link
Member

croqaz commented Jun 16, 2022

Hi @danawoodman .
I hope you don't mind if I close this issue, because it doesn't seem to be relevant anymore.
Feel free to create another issue if you still use Overseer.
Thank you!

@croqaz croqaz closed this as completed Jun 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants