1

I am running about 30 processes in parallel started from a bash script using:

/MyApp arg1 arg2 &

Where /MyApp is softlink to c# executable.

I notice in tasklist that there is a "sh.exe" for each MyApp I start.

Is this expected? Or am I starting the tasks incorrectly?

ManInMoon
  • 6,795
  • 15
  • 70
  • 133
  • Try using `exec /MyApp arg arg` and it will call your app without creating a new process. You won't be able to return to the script though. – John C Dec 01 '14 at 10:09
  • @JohnC So you would expect a sh.exe to be created for each new background job? – ManInMoon Dec 01 '14 at 10:12
  • If you are calling it from a shell script then yes. If you are calling it directly then possibly /MyApp is a shell script itself. – John C Dec 01 '14 at 10:15
  • No /MyApp is a c# executable - but I still get an sh.exe when called from script – ManInMoon Dec 01 '14 at 10:16
  • When you put it in the background you spawn another shell. `&` does that. Try putting an `exec` in front of your command as I first suggested. – John C Dec 01 '14 at 10:17
  • OK, exec appears cleaner - no sh.exes and work the same way for me. Any downside I should look out for? – ManInMoon Dec 01 '14 at 10:25
  • Nope not in this case I think you are fine. – John C Dec 01 '14 at 10:26

1 Answers1

0

Try running your command with exec, e.g.:

exec /MyApp arg1 arg2&

This will cause the /MyApp to replace the shell and then run in the background and you won't see an extra shell being spawned with every command.

John C
  • 4,276
  • 2
  • 17
  • 28