Launch multiple instances of console application executing shell commands

I have a console application that is processing some data from input and generating output files… The application is tarted multiple times by another application. Everything works well, however I am trying to add a shell command into the console application which is working fine as long as only one instance of console application is running. As soon as second one starts and a shell is created the applications shuts down with message “Killed”.

Is there any way to start multiple instances of a console application which is executing shell commands?

I’m a bit confused: There is one app A which starts multiple console apps B, and inside B there is a shell which crashes B?

Which shell mode? Which platform? What does that shell do?

There is no general problem with multiple console or service apps and shells, we use this a lot.

BTW, the worker app should be a service application, not console application.

The console application is just part of the whole system which has multiple parallel processes. So basically it goes as follows:
Application A (not my console app) is started 6 times on the server.
Application A is starting my console application that is generating different picture files based on parameters provided by Application A. This works and the outputs are generated simultaneously.

However now I have the need to start a shell command within my application and the problem is if 2 instances are running and shell is created (new shell) the instance quits with “Killed”

Not sure if I explain that clearly…

ok and what does the shell do?

The shell is starting a “ImageMagick” command which takes some time, but must be executed within the console application. The problem is already when I create the shell instance with dim sh as new shell - already here the console application is saying “Killed”, so I am not even able to launch the shell command.

Do you use a local variable for the shell (like dim s as new shell)?

Shell mode?

Yes, I use following:

dim sh as new Shell

Shell is synchronous since I need to wait for the output of the command before continuing the process - however tried as well with Asynchronous which gives same result.

Erik, this is hard to track down without the code.

Did you try to use service application instead of console application?

Are you sure the shell commands are correct? Try to start those shell commands manually within the terminal.

Yes, the shell commands are definitely ok and I can start the same in terminal without problem. As long as there is no other instance running the shell command it all works. (eg. first instance is generating the output and the shell command is currently executing), result is ok.

If I run the same console application (while first instance is running - with different set of data as input so it is not overlapping) it will break on “Dim sh as new shell”

I am very unfamiliar with service application, but will look into it.

Just change the Super of the application class to ServiceApplication, thats all in most cases.

What will happen if you do the same within one worker process? Starting 2 shells in 1 console app? Does it crash, too?

Starting multiple shells in same application works. This process is in a loop, however it is not starting multiple at the same time. I will try with service application and let you know if it works.

I am assuming at this point that there will be a problem with process is that is started when executing a shell. (Btw; the console app is working on Linux)

Keep in mind that running apps from a shell is not the same as running them from the terminal. For instance, it may not use the same interpreter as Terminal does by default. Also, the PATH environment variable is probably not set the same way.

Yes, I thought already that it might have something to do with the way how we start the console app, however tried in terminal (2 instances) and it also breaks as long as one of the console apps is executing she’ll command and the other is trying to create a shell

Try the second one by running it from the IDE. It may be crashing for some other reason.

Hi Greg,

Thanks for the response… I have tried another server (with same OS - centos 7) started 2 instances with input information and it all worked. There is no breaking.

I wonder what could be killing the instance from system point of view. I am not aware of any process that could do that on linux.

I’m still suggestion that you RUN the second instance from the IDE on that same machine , whether directly on the machine or using the remote debugger. Especially now that you’ve proven that this works on another machine. Your app could simply be running into a permissions issue which raises an exception and doing a debug run should highlight that for you.

FWIW, SELinux certainly could do what you are describing, as well as the process simply running out of RAM.