chazu / ypsilon

Automatically exported from code.google.com/p/ypsilon
Other
0 stars 1 forks source link

FEATURE REQUEST: process command #26

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Greetings,

I have a simple GUI using SDL which I have ported to Gambit, Ikarus, 
Larceny, and Chez scheme systems which I would like to run with Ypsilon.

To do this i need something like Ikarus's PROCESS command, which takes a 
command-string and spawns a process and returns 
 (values PID in-port out-port err-port) 
. [See attached C code].

Usage example:

(let-values ( [ (proc-id in-port out-port err-port) 
                  (process "./sdl-server")
                ]
              )

    (set! port->sdl      in-port)
    (set! sdl->port      (transcoded-port out-port (native-transcoder)))
    (set! sdl-error-port err-port)
    (set! sdl-procid     proc-id)
    )

Can you help me out?

Thanks much,
-KenD

PS: having a  process  command would allow PSTk to run as well 
[http://t3x.org/pstk/].

Original issue reported on code.google.com by Ken.Dic...@whidbey.com on 10 Jul 2008 at 1:13

Attachments:

GoogleCodeExporter commented 9 years ago
Thank you for your message. I will check it!

Original comment by y.fujita...@gmail.com on 10 Jul 2008 at 7:57

GoogleCodeExporter commented 9 years ago
I have added 'process' and 'process-wait' to (core) library.

Synopsis:
  (process <command> <args> ...) 
    <command>: string
    <args>:    string

Return Value:
  => (<process-id> <process-input> <process-output> <process-error>)
       <process-id>:     exact integer
       <process-input>:  binary output port
       <process-output>: binary input port
       <process-error>:  binary input port

Synopsis:
  (process-wait <process-id> <nohang>)
    <process-id>: exact integer
    <nohang>:     boolean

  if nohang == #t
     return #f if a <process-id> process is running otherwise return exit status of
<process-id> process.
  else
     wait until a <process-id> process has exited and return exit status of
<process-id> process.

Return Value:
  (process-wait pid #t) => #f or exact integer
  (process-wait pid #f) => exact integer

Example:

;;example1 (<nohang> == #f)
  (define p (process "ls" "-al"))
  (define from-process (transcoded-port (caddr p) (native-transcoder)))
  (display (get-string-all from-process)) ;=> print directory list
  (process-wait (car p) #f) ;=> 0
  (process-wait (car p) #f) ; "error in process-wait: waitpid() failed. No child
processes (10)"

;;example2 (<nohang> == #t)
  (define p (process "cat"))
  (define to-process (transcoded-port (cadr p) (native-transcoder)))
  (define from-process (transcoded-port (caddr p) (native-transcoder)))
  (put-string to-process "hello")
  (process-wait (car p) #t) ;=> #f
  (nonblock-byte-ready? from-process) ;=> #f
  (close-port to-process)
  (nonblock-byte-ready? from-process) ;=> #t
  (process-wait (car p) #t) ;=> 0
  (display (get-string-all from-process)) ;=> print "hello"
  (display (get-string-all from-process)) ;=> print "#<eof>"
  (put-string to-process "world") ; "error in put-string: expected opened port, but
got #<textual-output-port transcoded utf-8 closed>, as argument 1"
  (process-wait (car p) #t) ; "error in process-wait: waitpid() failed. No child
processes (10)"

;;example3 (<nohang> == #t, bad program)
  (define p (process "non-exist-program"))
  (define to-process (transcoded-port (cadr p) (native-transcoder)))
  (define from-process (transcoded-port (caddr p) (native-transcoder)))
  (put-string to-process "hello")
  (process-wait (car p) #t) ;=> 1

;;for pstk-new.scm
  (run-program
    (lambda (program)
      (destructuring-bind (_ in out _)
          (process program)
        (list (transcoded-port out (native-transcoder))
              (transcoded-port in (native-transcoder))))))
  (bottom (lambda (x) x))

---
Please try and let me know if there are any problems.
Thank you!

Original comment by y.fujita...@gmail.com on 12 Jul 2008 at 10:11

GoogleCodeExporter commented 9 years ago
Close.  I can't tell because of an apparent gc/heap bug.

See the "PleaseReadMe.txt" file in the GUI-Toy code.

-KenD
======================================================
Ypsilon 0.9.5-trunk Copyright (c) 2008 Y.Fujita, LittleWing Company Limited.
> (load "gui-toy.ss")

Process scheme segmentation fault
Ypsilon 0.9.5-trunk Copyright (c) 2008 Y.Fujita, LittleWing Company Limited.
> (load "gui-toy.ss")

> (run-test)

Process scheme broken pipe
Ypsilon 0.9.5-trunk Copyright (c) 2008 Y.Fujita, LittleWing Company Limited.
> (load "gui-toy.ss")

> (run-test)

Process scheme broken pipe
Ypsilon 0.9.5-trunk Copyright (c) 2008 Y.Fujita, LittleWing Company Limited.
> (load "gui-toy.ss")

> (run-test)

Process scheme broken pipe
Ypsilon 0.9.5-trunk Copyright (c) 2008 Y.Fujita, LittleWing Company Limited.
> (load "gui-toy.ss")

error: attempt call non-procedure: (((|if`11| (|not`11| ($ rectangle? 
shape) ...) ...) ...) ...)

backtrace:
  0  (new-announcer 'tick-announcer)
  ..."/usr/local/src/GUI-Toy/Ypsilon/gui-toy.ss" line 127
  1  (load "gui-toy.ss")
  ..."/dev/stdin" line 1
> (exit)

Process scheme finished
Ypsilon 0.9.5-trunk Copyright (c) 2008 Y.Fujita, LittleWing Company Limited.
> (load "gui-toy.ss")

> (run-test)

Process scheme broken pipe
Ypsilon 0.9.5-trunk Copyright (c) 2008 Y.Fujita, LittleWing Company Limited.
> (load "gui-toy.ss")

src/object_heap.cpp:109 collectible object over 1024 bytes not supported but 
1184 
bytes requested

Process scheme exited abnormally with code 1

Original comment by Ken.Dic...@whidbey.com on 12 Jul 2008 at 5:27

Attachments:

GoogleCodeExporter commented 9 years ago
Thank you for your bug report!
This issue reopened.

Original comment by y.fujita...@gmail.com on 13 Jul 2008 at 2:35

GoogleCodeExporter commented 9 years ago
I found several bugs (include bugs which cause segmentation fault and object 
size
overflow) and I fixed them.
Now I can run "gui-toy.ss" on my machine and I can see nice picture :)

However, still I can not reproduce "broken pipe" and "error: attempt call
non-procedure:" situation, so I'm not sure they are fixed or not. Please try 
trunk
version and let me know if it work. Thank you!

Original comment by y.fujita...@gmail.com on 14 Jul 2008 at 3:22

GoogleCodeExporter commented 9 years ago
kend@sealed:~/usr-local-src/GUI-Toy/Ypsilon>> ypsilon
Ypsilon 0.9.5-trunk Copyright (c) 2008 Y.Fujita, LittleWing Company Limited.
> (load "gui-toy.ss")
> (run-test)

## dies & returns to shell prompt
kend@sealed:~/usr-local-src/GUI-Toy/Ypsilon>> ypsilon
Ypsilon 0.9.5-trunk Copyright (c) 2008 Y.Fujita, LittleWing Company Limited.
> (load "gui-toy.ss")

error: attempt call non-procedure: (((|if`11| (|not`11| ($ rectangle? 
shape) ...) ...) ...) ...)

backtrace:
  0  (new-announcer 'tick-announcer)
  ..."/usr/local/src/GUI-Toy/Ypsilon/gui-toy.ss" line 127
  1  (load "gui-toy.ss")
  ..."/dev/stdin" line 1

> 

=========
I am running under the latest [k]ubuntu Linux [x86].

What other information can I give you?  
[E.g. compile ypsilon w debug flags on my machine].

Thanks,
-KenD

PS: The small square in the lower right corner is an 
"easter egg" you can click on.

Original comment by Ken.Dic...@whidbey.com on 14 Jul 2008 at 9:53

GoogleCodeExporter commented 9 years ago
>I am running under the latest [k]ubuntu Linux [x86].
May I have output of 'uname -a'?

>What other information can I give you?
>[E.g. compile ypsilon w debug flags on my machine].
Please try ypsilon with option '--disable-acc'. It should not solve this 
problem but
I want know if it change source code location where the error is happen. I'm now
making heap consistency check function. After done it, I will mail you.

>PS: The small square in the lower right corner is an "easter egg" you can 
click on.
I enjoyed it :)

Thank you!

Original comment by y.fujita...@gmail.com on 15 Jul 2008 at 1:52

GoogleCodeExporter commented 9 years ago
> uname -a
Linux sealed 2.6.24-19-generic #1 SMP Wed Jun 18 14:43:41 UTC 2008 i686 
GNU/Linux

I tried --disable-acc and also tried removing the fasl files from "~/.ypsilon" .

Now the app comes up about half the time, in the other cases the process 
terminates, 
or occasionally crashes the system.

Thkx,
-KenD

Original comment by Ken.Dic...@whidbey.com on 15 Jul 2008 at 3:33

GoogleCodeExporter commented 9 years ago
Thank you for your input!

Original comment by y.fujita...@gmail.com on 17 Jul 2008 at 3:21

GoogleCodeExporter commented 9 years ago
I tried again with the latest ypsilon-read-only trunk code.

Everything works fine now.

Thank you!!!
-KenD

Original comment by Ken.Dic...@whidbey.com on 17 Jul 2008 at 3:28

GoogleCodeExporter commented 9 years ago
It's Great!!! Many Thanks!!!

Original comment by y.fujita...@gmail.com on 18 Jul 2008 at 12:33