Question about process
Posted: Mon Jun 18, 2012 4:17 am
I wrote a simple program in linux
saved as 1.c
then I want to communicate this a.out with process and pipe...
it works at least, as you can see, this little codes is copy from newlisp manual
But I Can not get any result ,blocked in read-line
why is this happend?
My simple program is just like bc , I inputed something and hit enter key
then it print back what I inputed
But bc got work, So I am confused now
Code: Select all
#include <stdio.h>
int main ()
{
char str [80];
while(1)
{
fgets(str, 80, stdin);
printf("%s",str);
}
return 0;
}
then there is a a.outgcc 1.c
then I want to communicate this a.out with process and pipe...
Code: Select all
;; Linux/Unix
(map set '(myin bcout) (pipe))
(map set '(bcin myout) (pipe))
;; launch Unix 'bc' calculator application
(setq pid (process "./a.out" bcin bcout) )
(println pid)
(write myout "hello\n") ; bc expects a line-feed
(setq ret (read-line myin) )
(print ret)
;; destroy the process
(destroy pid)
But I Can not get any result ,blocked in read-line
why is this happend?
My simple program is just like bc , I inputed something and hit enter key
then it print back what I inputed
But bc got work, So I am confused now