FAQ
Hi,

Can you verify that os.Start() behaviour is different under windows and
linux?

I had to wrap an os.Start() like this:

func startServer(t *testing.T) {

cmd := exec.Command("./webserverInGo")

err := cmd.Start()

if err != nil {

t.Error(err)

}

}


func TestSomeIntegrationStuff(t *testing.T) {

...

if runtime.GOOS == "windows" {

go startServer(t)

} else {

startServer(t)

}

...


I could not find an issue for this. Should I raise one?


According to godoc:

func (*Cmd) Start <http://golang.org/src/pkg/os/exec/exec.go?s=6077:6104#L226>

func (c *Cmd) Start() error

Start starts the specified command but does not wait for it to complete.


Regards,

Kocka

--
Name : Kosztka Imre Dávid
E-mail: kosztkaid@gmail.com
Phone number: +36309213462
Mailing address: H-3700, Hungary Kazincbarcika Szeder utca 2.

--

Search Discussions

  • Dave Cheney at Nov 15, 2012 at 9:52 pm
    Are you saying that cmd.Start in windows does not return after starting the
    command? Try using t.Fatal to terminate the test immediately.

    Also, you are loosing the reference to your cmd object after starting it,
    how will you stop it?
    On 16 Nov 2012 08:42, "Kosztka Imre Dávid" wrote:

    Hi,

    Can you verify that os.Start() behaviour is different under windows and
    linux?

    I had to wrap an os.Start() like this:

    func startServer(t *testing.T) {

    cmd := exec.Command("./webserverInGo")

    err := cmd.Start()

    if err != nil {

    t.Error(err)

    }


    }


    func TestSomeIntegrationStuff(t *testing.T) {

    ...

    if runtime.GOOS == "windows" {

    go startServer(t)

    } else {

    startServer(t)


    }

    ...


    I could not find an issue for this. Should I raise one?


    According to godoc:

    func (*Cmd) Start <http://golang.org/src/pkg/os/exec/exec.go?s=6077:6104#L226>


    func (c *Cmd) Start() error

    Start starts the specified command but does not wait for it to complete.


    Regards,

    Kocka

    --
    Name : Kosztka Imre Dávid
    E-mail: kosztkaid@gmail.com
    Phone number: +36309213462
    Mailing address: H-3700, Hungary Kazincbarcika Szeder utca 2.

    --

    --
  • Kosztka Imre Dávid at Nov 15, 2012 at 10:03 pm
    Yes. I am saying that cmd.Start in windows does not return after starting
    the command.

    I am using a nasty hack:
    kill := exec.Command("taskkill", "/F", "/IM", "webserverInGo.exe")

    I could not find any exec.Kill(), and os/signal is not implemented in
    windows.

    The subject is wrong I was talking about exec.Start() and not
    os.StartProcess(). I can see an os.Kill() but no exec.Kill(). Right now I
    can not see why is os/exec usefull, there is no Kill(), and Start() does
    not look portable .


    2012/11/15 Dave Cheney <dave@cheney.net>
    Are you saying that cmd.Start in windows does not return after starting
    the command? Try using t.Fatal to terminate the test immediately.

    Also, you are loosing the reference to your cmd object after starting it,
    how will you stop it?
    On 16 Nov 2012 08:42, "Kosztka Imre Dávid" wrote:

    Hi,

    Can you verify that os.Start() behaviour is different under windows and
    linux?

    I had to wrap an os.Start() like this:

    func startServer(t *testing.T) {

    cmd := exec.Command("./webserverInGo")

    err := cmd.Start()

    if err != nil {

    t.Error(err)

    }


    }


    func TestSomeIntegrationStuff(t *testing.T) {

    ...

    if runtime.GOOS == "windows" {

    go startServer(t)

    } else {

    startServer(t)


    }

    ...


    I could not find an issue for this. Should I raise one?


    According to godoc:

    func (*Cmd) Start <http://golang.org/src/pkg/os/exec/exec.go?s=6077:6104#L226>


    func (c *Cmd) Start() error

    Start starts the specified command but does not wait for it to complete.


    Regards,

    Kocka

    --
    Name : Kosztka Imre Dávid
    E-mail: kosztkaid@gmail.com
    Phone number: +36309213462
    Mailing address: H-3700, Hungary Kazincbarcika Szeder utca 2.

    --


    --
    Name : Kosztka Imre Dávid
    E-mail: kosztkaid@gmail.com
    Phone number: +36309213462
    Mailing address: H-3700, Hungary Kazincbarcika Szeder utca 2.

    --
  • Jackie Li at Nov 15, 2012 at 10:28 pm
    you can do this: http://play.golang.org/p/VGB80xZ-Ce


    On Thu, Nov 15, 2012 at 10:03 PM, Kosztka Imre Dávid wrote:

    Yes. I am saying that cmd.Start in windows does not return after starting
    the command.

    I am using a nasty hack:
    kill := exec.Command("taskkill", "/F", "/IM", "webserverInGo.exe")

    I could not find any exec.Kill(), and os/signal is not implemented in
    windows.

    The subject is wrong I was talking about exec.Start() and not
    os.StartProcess(). I can see an os.Kill() but no exec.Kill(). Right now I
    can not see why is os/exec usefull, there is no Kill(), and Start() does
    not look portable .


    2012/11/15 Dave Cheney <dave@cheney.net>
    Are you saying that cmd.Start in windows does not return after starting
    the command? Try using t.Fatal to terminate the test immediately.

    Also, you are loosing the reference to your cmd object after starting it,
    how will you stop it?
    On 16 Nov 2012 08:42, "Kosztka Imre Dávid" wrote:

    Hi,

    Can you verify that os.Start() behaviour is different under windows and
    linux?

    I had to wrap an os.Start() like this:

    func startServer(t *testing.T) {

    cmd := exec.Command("./webserverInGo")

    err := cmd.Start()


    if err != nil {

    t.Error(err)

    }



    }


    func TestSomeIntegrationStuff(t *testing.T) {

    ...

    if runtime.GOOS == "windows" {

    go startServer(t)


    } else {


    startServer(t)



    }

    ...


    I could not find an issue for this. Should I raise one?


    According to godoc:

    func (*Cmd) Start <http://golang.org/src/pkg/os/exec/exec.go?s=6077:6104#L226>



    func (c *Cmd) Start() error

    Start starts the specified command but does not wait for it to complete.



    Regards,

    Kocka

    --
    Name : Kosztka Imre Dávid
    E-mail: kosztkaid@gmail.com
    Phone number: +36309213462
    Mailing address: H-3700, Hungary Kazincbarcika Szeder utca 2.

    --


    --
    Name : Kosztka Imre Dávid
    E-mail: kosztkaid@gmail.com
    Phone number: +36309213462
    Mailing address: H-3700, Hungary Kazincbarcika Szeder utca 2.

    --



    --
    Jackie

    --
  • Jackie Li at Nov 15, 2012 at 10:25 pm
    I don't know why your cmd.Start() doesn't return immediately, mine does. in
    the code I attached, the "sleep 10" returns and then got killed.

    On Thu, Nov 15, 2012 at 10:20 PM, Jackie Li wrote:

    you can do this: http://play.golang.org/p/VGB80xZ-Ce


    On Thu, Nov 15, 2012 at 10:03 PM, Kosztka Imre Dávid wrote:

    Yes. I am saying that cmd.Start in windows does not return after starting
    the command.

    I am using a nasty hack:
    kill := exec.Command("taskkill", "/F", "/IM", "webserverInGo.exe")

    I could not find any exec.Kill(), and os/signal is not implemented in
    windows.

    The subject is wrong I was talking about exec.Start() and not
    os.StartProcess(). I can see an os.Kill() but no exec.Kill(). Right now I
    can not see why is os/exec usefull, there is no Kill(), and Start() does
    not look portable .


    2012/11/15 Dave Cheney <dave@cheney.net>
    Are you saying that cmd.Start in windows does not return after starting
    the command? Try using t.Fatal to terminate the test immediately.

    Also, you are loosing the reference to your cmd object after starting
    it, how will you stop it?
    On 16 Nov 2012 08:42, "Kosztka Imre Dávid" wrote:

    Hi,

    Can you verify that os.Start() behaviour is different under windows and
    linux?

    I had to wrap an os.Start() like this:

    func startServer(t *testing.T) {

    cmd := exec.Command("./webserverInGo")

    err := cmd.Start()


    if err != nil {

    t.Error(err)

    }



    }


    func TestSomeIntegrationStuff(t *testing.T) {

    ...

    if runtime.GOOS == "windows" {

    go startServer(t)


    } else {


    startServer(t)



    }

    ...


    I could not find an issue for this. Should I raise one?


    According to godoc:

    func (*Cmd) Start <http://golang.org/src/pkg/os/exec/exec.go?s=6077:6104#L226>



    func (c *Cmd) Start() error

    Start starts the specified command but does not wait for it to complete.



    Regards,

    Kocka

    --
    Name : Kosztka Imre Dávid
    E-mail: kosztkaid@gmail.com
    Phone number: +36309213462
    Mailing address: H-3700, Hungary Kazincbarcika Szeder utca 2.

    --


    --
    Name : Kosztka Imre Dávid
    E-mail: kosztkaid@gmail.com
    Phone number: +36309213462
    Mailing address: H-3700, Hungary Kazincbarcika Szeder utca 2.

    --



    --
    Jackie


    --
    Jackie

    --
  • Brainman at Nov 15, 2012 at 10:54 pm

    On Friday, 16 November 2012 09:20:57 UTC+11, Jackie wrote:
    you can do this: http://play.golang.org/p/VGB80xZ-Ce
    I took liberty to modify yours http://play.golang.org/p/iqympnDiPG, so it
    actually works on windows.

    Alex

    --
  • Kosztka Imre Dávid at Nov 16, 2012 at 12:19 pm
    It is embarrassing. Now it works. I am failed. Thanks for the info on how
    to kill process!


    2012/11/15 brainman <alex.brainman@gmail.com>
    On Friday, 16 November 2012 09:20:57 UTC+11, Jackie wrote:

    you can do this: http://play.golang.org/**p/VGB80xZ-Ce<http://play.golang.org/p/VGB80xZ-Ce>
    I took liberty to modify yours http://play.golang.org/p/iqympnDiPG, so it
    actually works on windows.

    Alex


    --
    Name : Kosztka Imre Dávid
    E-mail: kosztkaid@gmail.com
    Phone number: +36309213462
    Mailing address: H-3700, Hungary Kazincbarcika Szeder utca 2.

    --

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedNov 15, '12 at 9:42p
activeNov 16, '12 at 12:19p
posts7
users4
websitegolang.org

People

Translate

site design / logo © 2022 Grokbase