launch second instance with "open elevated process"

If you find an issue in LiveCode but are having difficulty pinning down a reliable recipe or want to sanity-check your findings with others, this is the place.

Please have one thread per issue, and try to summarize the issue concisely in the thread title so others can find related issues here.

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller, robinmiller

Post Reply
Ledigimate
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 106
Joined: Mon Jan 14, 2013 3:37 pm

launch second instance with "open elevated process"

Post by Ledigimate » Fri Dec 02, 2016 8:44 am

Dear experts,

I'm experiencing two issues on Windows. My LiveCode app needs to launch a second instance of itself with elevated privileges.

I use the following code to launch the second instance:

Code: Select all

on openStack
   if $1 is empty then
      put $0 && "-slave" into tSlave
      open elevated process tSlave
   end if
end openStack
The first issue is that the second instance starts but doesn't show its user interface.

The second issue is that the following code doesn't work in the second instance. It executes but no file is created or modified. It works in the first instance but not in the second instance.

Code: Select all

   put "testfile.bin" into tTestFile
   open file tTestFile for binary write
   write "test" to file tTestFile
   close file tTestFile
Any idea why that is?
010100000110010101100001011000110110010100111101010011000110111101110110011001010010101101010100011100100111010101110100011010000010101101001010011101010111001101110100011010010110001101100101

Ledigimate
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 106
Joined: Mon Jan 14, 2013 3:37 pm

Re: launch second instance with "open elevated process"

Post by Ledigimate » Mon Dec 05, 2016 2:36 pm

I have resolved the second issue, and it wasn't LiveCode's fault. The second instance receives data from the first instance, specifying the name of the file to create. This data had a linefeed character at the end which, if not removed, caused the "open file" statement to fail with the result "can't open that file". I just removed the linefeed character and then it worked as expected.

The first issue is persistent, though.
010100000110010101100001011000110110010100111101010011000110111101110110011001010010101101010100011100100111010101110100011010000010101101001010011101010111001101110100011010010110001101100101

AxWald
Posts: 291
Joined: Thu Mar 06, 2014 2:57 pm

Re: launch second instance with "open elevated process"

Post by AxWald » Mon Dec 05, 2016 5:43 pm

Hi,

just tried with same results.
I'd try to change name for one somehow - two identical instances smell like danger.
Other thing, the slave will try to open another slave (via openstack msg), and so on - maybe it's this?

Hope I could help, maybe I'll give it a try if I find a piece of spare time. What's this good for, anyways? Care to explain?

Have fun!
Livecode programming until the cat hits the fan ...

Ledigimate
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 106
Joined: Mon Jan 14, 2013 3:37 pm

Re: launch second instance with "open elevated process"

Post by Ledigimate » Tue Dec 06, 2016 7:35 am

The application always checks the $1 command line argument and if it is "-slave" then it doesn't launch a second instance.

I can understand why two instances of the same application smell like danger, but I've made sure the second instance knows when it was launched in slave mode. There are some well-known applications that launch multiple instances of themselves without a problem, like Google Chrome. As long as each instance knows when it's the master or a slave process and can keep proper tabs on each, it shouldn't be a problem.

I need the application to perform blocking operations requiring elevated privileges without making the user interface appear non-responsive, and in LiveCode this master-slave approach is the closest we can get to actual multithreading.

EDIT: I've just discovered that on Windows XP the user interface for the second instance does appear. I'm suspecting it might have something to do with the Desktop Window Manager which Windows XP doesn't have... but it's still a bug in my opinion.
010100000110010101100001011000110110010100111101010011000110111101110110011001010010101101010100011100100111010101110100011010000010101101001010011101010111001101110100011010010110001101100101

Post Reply

Return to “Bug Triage”