unixCmd Improvements

View: New views
11 Messages — Rating Filter:   Alert me  

unixCmd Improvements

by Ryan Brown-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Attached is a patch (and two new files) for several improvements to String.unixCmd.

String.unixCmd(action, postOutput)

The return value is the pid of the newly created process. action is a Function that is called when the process has exited. It is passed two arguments: the exit code and pid of the process. postOutput is a Boolean, it should be obvious what it does.

I've also added Integer.pidRunning which returns a Boolean and allows you to check on the status of any pid on the system.

This stuff is similar to what Dan does in the ProcessTools quark, but everything is implemented in C. Because it doesn't have to poll and parse ps output it is faster and more robust.

I've tested it on OS X, Windows and Linux. The only thing that may be controversial is that code will break that depends on the return value being the original command string. I doubt that any code actually does that though.

Okay to commit?

Ryan






_______________________________________________
Sc-devel mailing list
Sc-devel@...
http://lists.create.ucsb.edu/mailman/listinfo/sc-devel

unixCmdImprovements.patch (9K) Download Attachment
sc_popen.cpp (7K) Download Attachment
sc_popen.h (941 bytes) Download Attachment

Re: unixCmd Improvements

by Ryan Brown-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> Attached is a patch (and two new files) for several improvements to  
> String.unixCmd.

Just realized that I had posted a patch against a previous version of  
these changes in my git repo. That attached patch is correct, and  
includes sc_popen.cpp an sc_popen.h.






_______________________________________________
Sc-devel mailing list
Sc-devel@...
http://lists.create.ucsb.edu/mailman/listinfo/sc-devel

unixCmdImprovements.patch (19K) Download Attachment

Re: unixCmd Improvements

by thor-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Hi Ryan

> The return value is the pid of the newly created process. action is  
> a Function that is called when the process has exited. It is passed  
> two arguments: the exit code and pid of the process. postOutput is  
> a Boolean, it should be obvious what it does.

This is fantastic!

> I've tested it on OS X, Windows and Linux. The only thing that may  
> be controversial is that code will break that depends on the return  
> value being the original command string. I doubt that any code  
> actually does that though.

Wow. Even on Windows! This removes lots of headaches
for me and Enrike as we were going to port stuff to Windows.

Thor

_______________________________________________
Sc-devel mailing list
Sc-devel@...
http://lists.create.ucsb.edu/mailman/listinfo/sc-devel

Re: unixCmd Improvements

by blackrain-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

just patched my copy and testing some of my code that relayed on pipes.
works great Ryan.

thanks.

On Thu, Mar 27, 2008 at 4:50 PM, Ryan Brown <ryan@...> wrote:

> Attached is a patch (and two new files) for several improvements to
> String.unixCmd.
>
> String.unixCmd(action, postOutput)
>
> The return value is the pid of the newly created process. action is a
> Function that is called when the process has exited. It is passed two
> arguments: the exit code and pid of the process. postOutput is a Boolean, it
> should be obvious what it does.
>
> I've also added Integer.pidRunning which returns a Boolean and allows you to
> check on the status of any pid on the system.
>
> This stuff is similar to what Dan does in the ProcessTools quark, but
> everything is implemented in C. Because it doesn't have to poll and parse ps
> output it is faster and more robust.
>
> I've tested it on OS X, Windows and Linux. The only thing that may be
> controversial is that code will break that depends on the return value being
> the original command string. I doubt that any code actually does that
> though.
>

> Okay to commit?
>
> Ryan
>

please!

x


>
>
>
> _______________________________________________
>  Sc-devel mailing list
>  Sc-devel@...
>  http://lists.create.ucsb.edu/mailman/listinfo/sc-devel
>
>
_______________________________________________
Sc-devel mailing list
Sc-devel@...
http://lists.create.ucsb.edu/mailman/listinfo/sc-devel

Re: unixCmd Improvements

by blackrain-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

forgot to mention.
the patch doesnt include the lang primitive call for Integer:pidRunning.

+Integer {
        pidRunning {
                _PidRunning;
                ^this.primitiveFailed
        }
}

thanks again Ryan.

x

On Thu, Mar 27, 2008 at 7:03 PM, blackrain <blackrain.sc@...> wrote:

> just patched my copy and testing some of my code that relayed on pipes.
>  works great Ryan.
>
>  thanks.
>
>
>
>  On Thu, Mar 27, 2008 at 4:50 PM, Ryan Brown <ryan@...> wrote:
>  > Attached is a patch (and two new files) for several improvements to
>  > String.unixCmd.
>  >
>  > String.unixCmd(action, postOutput)
>  >
>  > The return value is the pid of the newly created process. action is a
>  > Function that is called when the process has exited. It is passed two
>  > arguments: the exit code and pid of the process. postOutput is a Boolean, it
>  > should be obvious what it does.
>  >
>  > I've also added Integer.pidRunning which returns a Boolean and allows you to
>  > check on the status of any pid on the system.
>  >
>  > This stuff is similar to what Dan does in the ProcessTools quark, but
>  > everything is implemented in C. Because it doesn't have to poll and parse ps
>  > output it is faster and more robust.
>  >
>  > I've tested it on OS X, Windows and Linux. The only thing that may be
>  > controversial is that code will break that depends on the return value being
>  > the original command string. I doubt that any code actually does that
>  > though.
>  >
>
>  > Okay to commit?
>  >
>  > Ryan
>  >
>
>  please!
>
>
>
>  x
>
>
>  >
>  >
>  >
>  > _______________________________________________
>  >  Sc-devel mailing list
>  >  Sc-devel@...
>  >  http://lists.create.ucsb.edu/mailman/listinfo/sc-devel
>  >
>  >
>
_______________________________________________
Sc-devel mailing list
Sc-devel@...
http://lists.create.ucsb.edu/mailman/listinfo/sc-devel

Re: unixCmd Improvements

by ronald kuivila :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

yes, this is just wonderful!

RJK

On Mar 27, 2008, at 9:08 PM, blackrain wrote:

> forgot to mention.
> the patch doesnt include the lang primitive call for  
> Integer:pidRunning.
>
> +Integer {
> pidRunning {
> _PidRunning;
> ^this.primitiveFailed
> }
> }
>
> thanks again Ryan.
>
> x
>
> On Thu, Mar 27, 2008 at 7:03 PM, blackrain <blackrain.sc@...>  
> wrote:
>> just patched my copy and testing some of my code that relayed on  
>> pipes.
>>  works great Ryan.
>>
>>  thanks.
>>
>>
>>
>>  On Thu, Mar 27, 2008 at 4:50 PM, Ryan Brown <ryan@...> wrote:
>>> Attached is a patch (and two new files) for several improvements to
>>> String.unixCmd.
>>>
>>> String.unixCmd(action, postOutput)
>>>
>>> The return value is the pid of the newly created process. action  
>>> is a
>>> Function that is called when the process has exited. It is passed  
>>> two
>>> arguments: the exit code and pid of the process. postOutput is a  
>>> Boolean, it
>>> should be obvious what it does.
>>>
>>> I've also added Integer.pidRunning which returns a Boolean and  
>>> allows you to
>>> check on the status of any pid on the system.
>>>
>>> This stuff is similar to what Dan does in the ProcessTools quark,  
>>> but
>>> everything is implemented in C. Because it doesn't have to poll  
>>> and parse ps
>>> output it is faster and more robust.
>>>
>>> I've tested it on OS X, Windows and Linux. The only thing that  
>>> may be
>>> controversial is that code will break that depends on the return  
>>> value being
>>> the original command string. I doubt that any code actually does  
>>> that
>>> though.
>>>
>>
>>> Okay to commit?
>>>
>>> Ryan
>>>
>>
>>  please!
>>
>>
>>
>>  x
>>
>>
>>>
>>>
>>>
>>> _______________________________________________
>>>  Sc-devel mailing list
>>>  Sc-devel@...
>>>  http://lists.create.ucsb.edu/mailman/listinfo/sc-devel
>>>
>>>
>>
> _______________________________________________
> Sc-devel mailing list
> Sc-devel@...
> http://lists.create.ucsb.edu/mailman/listinfo/sc-devel
>

_______________________________________________
Sc-devel mailing list
Sc-devel@...
http://lists.create.ucsb.edu/mailman/listinfo/sc-devel

Re: unixCmd Improvements

by Ryan Brown-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

After a month of laziness I finally committed this (and the docs to go  
with it). Getting it to work on Windows turned out to be much more  
difficult than I thought...but it was interesting getting my hands  
dirty with Visual Studio and the Win32 APIs.

Ryan

On Mar 28, 2008, at 6:08 AM, ronald kuivila wrote:

> yes, this is just wonderful!
>
> RJK
>
> On Mar 27, 2008, at 9:08 PM, blackrain wrote:
>
>> forgot to mention.
>> the patch doesnt include the lang primitive call for
>> Integer:pidRunning.
>>
>> +Integer {
>> pidRunning {
>> _PidRunning;
>> ^this.primitiveFailed
>> }
>> }
>>
>> thanks again Ryan.
>>
>> x
>>
>> On Thu, Mar 27, 2008 at 7:03 PM, blackrain <blackrain.sc@...>
>> wrote:
>>> just patched my copy and testing some of my code that relayed on
>>> pipes.
>>> works great Ryan.
>>>
>>> thanks.
>>>
>>>
>>>
>>> On Thu, Mar 27, 2008 at 4:50 PM, Ryan Brown <ryan@...> wrote:
>>>> Attached is a patch (and two new files) for several improvements to
>>>> String.unixCmd.
>>>>
>>>> String.unixCmd(action, postOutput)
>>>>
>>>> The return value is the pid of the newly created process. action
>>>> is a
>>>> Function that is called when the process has exited. It is passed
>>>> two
>>>> arguments: the exit code and pid of the process. postOutput is a
>>>> Boolean, it
>>>> should be obvious what it does.
>>>>
>>>> I've also added Integer.pidRunning which returns a Boolean and
>>>> allows you to
>>>> check on the status of any pid on the system.
>>>>
>>>> This stuff is similar to what Dan does in the ProcessTools quark,
>>>> but
>>>> everything is implemented in C. Because it doesn't have to poll
>>>> and parse ps
>>>> output it is faster and more robust.
>>>>
>>>> I've tested it on OS X, Windows and Linux. The only thing that
>>>> may be
>>>> controversial is that code will break that depends on the return
>>>> value being
>>>> the original command string. I doubt that any code actually does
>>>> that
>>>> though.
>>>>
>>>
>>>> Okay to commit?
>>>>
>>>> Ryan
>>>>
>>>
>>> please!
>>>
>>>
>>>
>>> x
>>>
>>>
>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>> Sc-devel mailing list
>>>> Sc-devel@...
>>>> http://lists.create.ucsb.edu/mailman/listinfo/sc-devel
>>>>
>>>>
>>>
>> _______________________________________________
>> Sc-devel mailing list
>> Sc-devel@...
>> http://lists.create.ucsb.edu/mailman/listinfo/sc-devel
>>
>
> _______________________________________________
> Sc-devel mailing list
> Sc-devel@...
> http://lists.create.ucsb.edu/mailman/listinfo/sc-devel
>

_______________________________________________
Sc-devel mailing list
Sc-devel@...
http://lists.create.ucsb.edu/mailman/listinfo/sc-devel

Re: unixCmd Improvements

by Dan Stowell :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Well thanks for making my ProcessTools quark superfluous ;)

Seriously though I'm v much looking forward to trying this, should be
a much better way of connecting with the commandline. The ProcessTools
stuff is a long way to work around SC's old unixCmd behaviour.

Dan

2008/5/13 Ryan Brown <ryan@...>:

> After a month of laziness I finally committed this (and the docs to go
>  with it). Getting it to work on Windows turned out to be much more
>  difficult than I thought...but it was interesting getting my hands
>  dirty with Visual Studio and the Win32 APIs.
>
>  Ryan
>
>
>
>  On Mar 28, 2008, at 6:08 AM, ronald kuivila wrote:
>
>  > yes, this is just wonderful!
>  >
>  > RJK
>  >
>  > On Mar 27, 2008, at 9:08 PM, blackrain wrote:
>  >
>  >> forgot to mention.
>  >> the patch doesnt include the lang primitive call for
>  >> Integer:pidRunning.
>  >>
>  >> +Integer {
>  >>      pidRunning {
>  >>              _PidRunning;
>  >>              ^this.primitiveFailed
>  >>      }
>  >> }
>  >>
>  >> thanks again Ryan.
>  >>
>  >> x
>  >>
>  >> On Thu, Mar 27, 2008 at 7:03 PM, blackrain <blackrain.sc@...>
>  >> wrote:
>  >>> just patched my copy and testing some of my code that relayed on
>  >>> pipes.
>  >>> works great Ryan.
>  >>>
>  >>> thanks.
>  >>>
>  >>>
>  >>>
>  >>> On Thu, Mar 27, 2008 at 4:50 PM, Ryan Brown <ryan@...> wrote:
>  >>>> Attached is a patch (and two new files) for several improvements to
>  >>>> String.unixCmd.
>  >>>>
>  >>>> String.unixCmd(action, postOutput)
>  >>>>
>  >>>> The return value is the pid of the newly created process. action
>  >>>> is a
>  >>>> Function that is called when the process has exited. It is passed
>  >>>> two
>  >>>> arguments: the exit code and pid of the process. postOutput is a
>  >>>> Boolean, it
>  >>>> should be obvious what it does.
>  >>>>
>  >>>> I've also added Integer.pidRunning which returns a Boolean and
>  >>>> allows you to
>  >>>> check on the status of any pid on the system.
>  >>>>
>  >>>> This stuff is similar to what Dan does in the ProcessTools quark,
>  >>>> but
>  >>>> everything is implemented in C. Because it doesn't have to poll
>  >>>> and parse ps
>  >>>> output it is faster and more robust.
>  >>>>
>  >>>> I've tested it on OS X, Windows and Linux. The only thing that
>  >>>> may be
>  >>>> controversial is that code will break that depends on the return
>  >>>> value being
>  >>>> the original command string. I doubt that any code actually does
>  >>>> that
>  >>>> though.
>  >>>>
>  >>>
>  >>>> Okay to commit?
>  >>>>
>  >>>> Ryan
>  >>>>
>  >>>
>  >>> please!
>  >>>
>  >>>
>  >>>
>  >>> x
>  >>>
>  >>>
>  >>>>
>  >>>>
>  >>>>
>  >>>> _______________________________________________
>  >>>> Sc-devel mailing list
>  >>>> Sc-devel@...
>  >>>> http://lists.create.ucsb.edu/mailman/listinfo/sc-devel
>  >>>>
>  >>>>
>  >>>
>  >> _______________________________________________
>  >> Sc-devel mailing list
>  >> Sc-devel@...
>  >> http://lists.create.ucsb.edu/mailman/listinfo/sc-devel
>  >>
>  >
>  > _______________________________________________
>  > Sc-devel mailing list
>  > Sc-devel@...
>  > http://lists.create.ucsb.edu/mailman/listinfo/sc-devel
>  >
>
>  _______________________________________________
>  Sc-devel mailing list
>  Sc-devel@...
>  http://lists.create.ucsb.edu/mailman/listinfo/sc-devel
>



--
http://www.mcld.co.uk
_______________________________________________
Sc-devel mailing list
Sc-devel@...
http://lists.create.ucsb.edu/mailman/listinfo/sc-devel

Re: unixCmd Improvements

by stefan kersten-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

hi ryan,

On 13.05.2008, at 08:41, Ryan Brown wrote:
> After a month of laziness I finally committed this (and the docs to go
> with it). Getting it to work on Windows turned out to be much more
> difficult than I thought...but it was interesting getting my hands
> dirty with Visual Studio and the Win32 APIs.

i get a link error when building with scons on osx:

g++ -o build/libsclang.dylib -framework CoreServices -framework
CoreAudio -framework CoreMIDI -framework Carbon -framework IOKit
-framework IOBluetooth -dynamiclib
[... objects ...]
Source/lang/LangPrimSource/SC_Speech.os -Lbuild -L/usr/local/lib
-lcommon -lscsynth -lpthread -ldl -lm -licucore -lsndfile
ld: Undefined symbols:
_environ
/usr/libexec/gcc/i686-apple-darwin8/4.0.1/libtool: internal link edit  
command failed
scons: *** [build/libsclang.dylib] Error 1
scons: building terminated because of errors.

any ideas?

<sk>

_______________________________________________
Sc-devel mailing list
Sc-devel@...
http://lists.create.ucsb.edu/mailman/listinfo/sc-devel

Re: unixCmd Improvements

by Ryan Brown-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> i get a link error when building with scons on osx:
>
> g++ -o build/libsclang.dylib -framework CoreServices -framework
> CoreAudio -framework CoreMIDI -framework Carbon -framework IOKit
> -framework IOBluetooth -dynamiclib
> [... objects ...]
> Source/lang/LangPrimSource/SC_Speech.os -Lbuild -L/usr/local/lib
> -lcommon -lscsynth -lpthread -ldl -lm -licucore -lsndfile
> ld: Undefined symbols:
> _environ
> /usr/libexec/gcc/i686-apple-darwin8/4.0.1/libtool: internal link edit
> command failed
> scons: *** [build/libsclang.dylib] Error 1
> scons: building terminated because of errors.
>
> any ideas?

I just committed a fix that should fix this, along with allowing for  
building against the 10.5 SDK. Let me know if it works, I haven't  
tried it on Tiger myself.

Ryan
_______________________________________________
Sc-devel mailing list
Sc-devel@...
http://lists.create.ucsb.edu/mailman/listinfo/sc-devel

Re: unixCmd Improvements

by stefan kersten-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On 15.05.2008, at 03:51, Ryan Brown wrote:
>> I just committed a fix that should fix this, along with allowing for
> building against the 10.5 SDK. Let me know if it works, I haven't
> tried it on Tiger myself.

thanks ryan, works fine on tiger.

<sk>

_______________________________________________
Sc-devel mailing list
Sc-devel@...
http://lists.create.ucsb.edu/mailman/listinfo/sc-devel
LightInTheBox - Buy quality products at wholesale price