Challenge: who can background this shell command?

Dar Scott Consulting dsc at swcp.com
Fri Aug 2 10:13:06 EDT 2019


I'm assuming you can send the ^c down the process connection. That is, write to the opened process. Wait a bit after that or look at the response, and then shut down the polling send-loop and then close the connection if it is not already closed, 

It might be that simply closing the connection to the process will cause it to shutdown gracefully. However, it would be nice to see the graceful shutdown.

I'd collect the reads and put them in a field on a stack just for monitoring the output. You can make it development only or you can make it part of your thing. This will allow you to see what is going on. It also allows you to see why Dar's idea of sending ^c doesn't work.

> On Aug 2, 2019, at 7:13 AM, David Bovill via use-livecode <use-livecode at lists.runrev.com> wrote:
> 
> Yes - ^c to shut down... but why for update?
> 
> On Thu, 1 Aug 2019 at 19:27, Dar Scott Consulting via use-livecode <
> use-livecode at lists.runrev.com> wrote:
> 
>> I am not familiar with hugo. Do you type a ^c to shut down hugo server? In
>> that case you might want to consider open for update.
>> 
>>> On Aug 1, 2019, at 12:19 PM, David Bovill via use-livecode <
>> use-livecode at lists.runrev.com> wrote:
>>> 
>>> OK - I managed to get it to work with:
>>> 
>>>  - open process "/usr/local/bin/hugo server" for read
>>> 
>>> which I did not think would work due to the two word shell command.
>>> 
>>> Timing was an issue - so I had to use the method found here (thanks
>> Mark) -
>>> 
>> https://github.com/livecode/livecode/blob/develop/builder/installer_utilities.livecodescript
>>> -
>>> which uses a send in 20 milliseconds when there is a timeout. basically
>> it
>>> is complex timing logic, but more direct and probably robust than using a
>>> bunch of shell commands we put into the background. Still we have tow
>>> methods that work - restores my faith in the flexibility of Livecode!
>>> 
>>> On Thu, 1 Aug 2019 at 17:15, dsc--- via use-livecode <
>>> use-livecode at lists.runrev.com> wrote:
>>> 
>>>> I feel foolish. From the dictionary:
>>>> 
>>>> 
>>>> Note: On OS X systems, you can use the open process command to start up
>> an
>>>> application, but not a Unix process. To work with a Unix process, use
>> the
>>>> shell func instead.
>>>> 
>>>> When I saw this in the Dictionary, I thought, "Oh, when did this break?"
>>>> 
>>>> I should have thought, "Oh, yeah?"
>>>> 
>>>> 
>>>>> On Aug 1, 2019, at 10:03 AM, Dar Scott Consulting via use-livecode <
>>>> use-livecode at lists.runrev.com> wrote:
>>>>> 
>>>>> So, this is a documentation problem?
>>>>> 
>>>>>> On Aug 1, 2019, at 9:27 AM, Mark Waddingham via use-livecode <
>>>> use-livecode at lists.runrev.com> wrote:
>>>>>> 
>>>>>> On 2019-08-01 17:12, David Bovill via use-livecode wrote:
>>>>>>> OK - so I have it working by writing to a temporary file.
>>>>>>> Trying to redirect the output to stdout - so that shell() return the
>>>>>>> information of the background process - but this freezes:
>>>>>> 
>>>>>> Okay so given you want to read/write to the process you launched it
>>>> seems...
>>>>>> 
>>>>>> What's wrong with open process? The *only* difference between open
>>>> process
>>>>>> on macOS compared to Linux (and Windows) is that if you try and open
>>>> process
>>>>>> an app-bundle (i.e. something ending with '.app') it will do the same
>> as
>>>>>> launch (as .app bundles aren't executables).
>>>>>> 
>>>>>> The installer uses open (elevated) process to communicate with an
>>>> instance
>>>>>> of itself with elevated permissions. You can see the code for that
>> here:
>>>>>> 
>>>>>> <
>>>> 
>> https://github.com/livecode/livecode/blob/develop/builder/installer_utilities.livecodescript
>>>>> 
>>>>>> 
>>>>>> The key routines are installerRun and installerMonitor (the latter is
>>>> used
>>>>>> to poll every 20 milliseconds to check if the child process has
>>>> anything to
>>>>>> say).
>>>>>> 
>>>>>> Warmest Regards,
>>>>>> 
>>>>>> Mark.
>>>>>> 
>>>>>> --
>>>>>> Mark Waddingham ~ mark at livecode.com ~ http://www.livecode.com/
>>>>>> LiveCode: Everyone can create apps
>>>>>> 
>>>>>> _______________________________________________
>>>>>> use-livecode mailing list
>>>>>> use-livecode at lists.runrev.com
>>>>>> Please visit this url to subscribe, unsubscribe and manage your
>>>> subscription preferences:
>>>>>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>>>>> 
>>>>> 
>>>>> 
>>>>> _______________________________________________
>>>>> use-livecode mailing list
>>>>> use-livecode at lists.runrev.com
>>>>> Please visit this url to subscribe, unsubscribe and manage your
>>>> subscription preferences:
>>>>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>>> 
>>>> _______________________________________________
>>>> use-livecode mailing list
>>>> use-livecode at lists.runrev.com
>>>> Please visit this url to subscribe, unsubscribe and manage your
>>>> subscription preferences:
>>>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>>> 
>>> _______________________________________________
>>> use-livecode mailing list
>>> use-livecode at lists.runrev.com
>>> Please visit this url to subscribe, unsubscribe and manage your
>> subscription preferences:
>>> http://lists.runrev.com/mailman/listinfo/use-livecode
>> 
>> 
>> _______________________________________________
>> use-livecode mailing list
>> use-livecode at lists.runrev.com
>> Please visit this url to subscribe, unsubscribe and manage your
>> subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
>> 
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
> 





More information about the Use-livecode mailing list