can anybody demonstrate the pipe creates new instance of cmd, issue?

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
taripo
Posts: 228
Joined: 01 Aug 2011 13:48

can anybody demonstrate the pipe creates new instance of cmd, issue?

#1 Post by taripo » 21 Mar 2017 10:49

I've often heard that pipes create a new instance of cmd..

I don't see it though

If I go to e.g. the windows directory and I do dir /p | more, then I don't see a new cmd.exe instance appear in task manager.

i'm also interested in when that has ramifications that some might not foresee.

thanks

aGerman
Expert
Posts: 4678
Joined: 22 Jan 2010 18:01
Location: Germany

Re: can anybody demonstrate the pipe creates new instance of cmd, issue?

#2 Post by aGerman » 21 Mar 2017 13:45

The new instance is most likely alredy terminated before the Task Manager updated the list. You will need blocking commands. E.g.

Code: Select all

pause>nul|set /p "=Hello, World!"


Steffen

taripo
Posts: 228
Joined: 01 Aug 2011 13:48

Re: can anybody demonstrate the pipe creates new instance of cmd, issue?

#3 Post by taripo » 21 Mar 2017 15:17

it seems to create two command processes

Code: Select all

pause>nul|set /p=sdf


seems to be creating two cmd processes

So if I open a cmd.exe window, I have one showing in task manager

then I run that and I get 3 running. So it created two.

why?

I notice that pause or pause>nul, doesn't create a cmd process. So it seems like the pipe to set /p=asdf creates two.

aGerman
Expert
Posts: 4678
Joined: 22 Jan 2010 18:01
Location: Germany

Re: can anybody demonstrate the pipe creates new instance of cmd, issue?

#4 Post by aGerman » 21 Mar 2017 15:33

That's what Process Explorer shows:
pipe.PNG
pipe.PNG (9.64 KiB) Viewed 6848 times


Steffen


dbenham
Expert
Posts: 2461
Joined: 12 Feb 2011 21:02
Location: United States (east coast)

Re: can anybody demonstrate the pipe creates new instance of cmd, issue?

#6 Post by dbenham » 21 Mar 2017 16:37

You should read the Q&A at http://stackoverflow.com/q/8192318/1012053.

There are lots of consequences discussed there.


Dave Benham

Post Reply