Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > ctrl - c not working in pipe

Reply
Thread Tools

ctrl - c not working in pipe

 
 
peter
Guest
Posts: n/a
 
      08-17-2009
Dear All


ProcessBuilder pb = new ProcessBuilder(bochsPath, "-q", "-f",
"bochsrc.bxrc");
pb.directory(new File("test"));
pb.redirectErrorStream(true);

p = pb.start();
p.getOutputStream.write((byte)0x3); <---- I want to send a SININT,
ctrl -c signal, but not working

thanks
from Peter ()
 
Reply With Quote
 
 
 
 
Lew
Guest
Posts: n/a
 
      08-17-2009
peter wrote:
> Dear All
>
>
> ProcessBuilder pb = new ProcessBuilder(bochsPath, "-q", "-f",
> "bochsrc.bxrc");
> pb.directory(new File("test"));
> pb.redirectErrorStream(true);
>
> p = pb.start();
> p.getOutputStream.write((byte)0x3); <---- I want to send a SININT,
> ctrl -c signal, but not working


0x3 is just a value - it doesn't trigger a signal unless the OS receives a
command to send a signal. The keyboard driver has a trap to convert "Ctrl-C"
into a signal, which the OS delivers instead of a byte with value 3. What you
did is bypass that mechanism and simply send the byte.

You can see this in Linux or Cygwin or any bash shell environment by entering
the command
$ echo $'\x3'this is a test

That merely sends the byte "0x03" to the output but does not raise the signal
that Ctrl-C would.

I'm sorry; I don't know how to send the signal.

--
Lew
 
Reply With Quote
 
 
 
 
Lew
Guest
Posts: n/a
 
      08-17-2009
Lew wrote:
> peter wrote:
>> Dear All
>>
>>
>> ProcessBuilder pb = new ProcessBuilder(bochsPath, "-q", "-f",
>> "bochsrc.bxrc");
>> pb.directory(new File("test"));
>> pb.redirectErrorStream(true);
>>
>> p = pb.start();
>> p.getOutputStream.write((byte)0x3); <---- I want to send a SININT,
>> ctrl -c signal, but not working

>
> 0x3 is just a value - it doesn't trigger a signal unless the OS receives
> a command to send a signal. The keyboard driver has a trap to convert
> "Ctrl-C" into a signal, which the OS delivers instead of a byte with
> value 3. What you did is bypass that mechanism and simply send the byte.
>
> You can see this in Linux or Cygwin or any bash shell environment by
> entering the command
> $ echo $'\x3'this is a test
>
> That merely sends the byte "0x03" to the output but does not raise the
> signal that Ctrl-C would.
>
> I'm sorry; I don't know how to send the signal.


Unless you figure out the process id (PID) of the started 'Process' and issue
a "kill -int <PID>" to it.

--
Lew
 
Reply With Quote
 
John B. Matthews
Guest
Posts: n/a
 
      08-17-2009
In article <h6akto$bnf$>, Lew <>
wrote:

> Lew wrote:
> > peter wrote:
> >> Dear All
> >>
> >> ProcessBuilder pb = new ProcessBuilder(bochsPath, "-q", "-f",
> >> "bochsrc.bxrc");
> >> pb.directory(new File("test"));
> >> pb.redirectErrorStream(true);
> >>
> >> p = pb.start();
> >> p.getOutputStream.write((byte)0x3); <---- I want to send a SININT,
> >> ctrl -c signal, but not working

> >
> > 0x3 is just a value - it doesn't trigger a signal unless the OS
> > receives a command to send a signal. The keyboard driver has a
> > trap to convert "Ctrl-C" into a signal, which the OS delivers
> > instead of a byte with value 3. What you did is bypass that
> > mechanism and simply send the byte.
> >
> > You can see this in Linux or Cygwin or any bash shell environment
> > by entering the command
> > $ echo $'\x3'this is a test
> >
> > That merely sends the byte "0x03" to the output but does not raise
> > the signal that Ctrl-C would.
> >
> > I'm sorry; I don't know how to send the signal.

>
> Unless you figure out the process id (PID) of the started 'Process'
> and issue a "kill -int <PID>" to it.


The kill command is a good, general-purpose way to send any signal:

<http://linux.die.net/man/2/kill>

Getting the PID can be cumbersome, and writing the PID to a file may be
convenient. Many system services store the value in /var/log/*.pid. In
this case, I wonder if the OP might simply use p.destroy() instead.

--
John B. Matthews
trashgod at gmail dot com
<http://sites.google.com/site/drjohnbmatthews>
 
Reply With Quote
 
Roedy Green
Guest
Posts: n/a
 
      08-17-2009
On Sun, 16 Aug 2009 20:44:26 -0700 (PDT), peter <>
wrote, quoted or indirectly quoted someone who said :

>p.getOutputStream.write((byte)0x3); <---- I want to send a SININT,
>ctrl -c signal, but not working


Other than the problems others have mentioned, a byte can get stuck
because you did not flush, or because the input is blocking. You
really need multiple threads to control a child.

see http://mindprod.com/jgloss/exec.html

--
Roedy Green Canadian Mind Products
http://mindprod.com

http://thecovemovie.com : The Cove: a documentary about Japan's secret atrocities against dolphins.
 
Reply With Quote
 
peter
Guest
Posts: n/a
 
      08-18-2009
On 8月18日, 上午3時06分, Roedy Green <see_webs...@mindprod.com.invalid>
wrote:
> On Sun, 16 Aug 2009 20:44:26 -0700 (PDT), peter <cmk...@gmail.com>
> wrote, quoted or indirectly quoted someone who said :
>
> >p.getOutputStream.write((byte)0x3); <---- *I want to send a SININT,
> >ctrl -c signal, but not working

>
> Other than the problems others have mentioned, a byte can get stuck
> because you did not flush, or because the input is blocking. *You
> really need multiple threads to control a child.
>
> seehttp://mindprod.com/jgloss/exec.html
>
> --
> Roedy Green Canadian Mind Productshttp://mindprod.com
>
> http://thecovemovie.com: The Cove: a documentary about Japan's secret atrocities against dolphins.


searched around for several days. Java has no ability to send SIGINT
to other process. Even in visual c++, no way to do it too.
thanks
from Peter
 
Reply With Quote
 
Lew
Guest
Posts: n/a
 
      08-18-2009
peter wrote:
> searched around for several days. Java has no ability to send SIGINT
> to other process. Even in visual c++, no way to do it too.


No direct ability. Java can do it indirectly as described upthread.

--
Lew
 
Reply With Quote
 
Mike Schilling
Guest
Posts: n/a
 
      08-18-2009
peter wrote:
> On 8?18?, ??3?06?, Roedy Green <see_webs...@mindprod.com.invalid>
> wrote:
>> On Sun, 16 Aug 2009 20:44:26 -0700 (PDT), peter <cmk...@gmail.com>
>> wrote, quoted or indirectly quoted someone who said :
>>
>>> p.getOutputStream.write((byte)0x3); <---- I want to send a SININT,
>>> ctrl -c signal, but not working

>>
>> Other than the problems others have mentioned, a byte can get stuck
>> because you did not flush, or because the input is blocking. You
>> really need multiple threads to control a child.
>>
>> seehttp://mindprod.com/jgloss/exec.html


>
> searched around for several days. Java has no ability to send SIGINT
> to other process


Since SIGINT is OS-specific, that's what you'd expect.


 
Reply With Quote
 
peter
Guest
Posts: n/a
 
      08-19-2009
On 8月19日, 上午1時10分, "Mike Schilling" <mscottschill...@hotmail.com>
wrote:
> peter wrote:
> > On 8?18?, ??3?06?, Roedy Green <see_webs...@mindprod.com.invalid>
> > wrote:
> >> On Sun, 16 Aug 2009 20:44:26 -0700 (PDT), peter <cmk...@gmail.com>
> >> wrote, quoted or indirectly quoted someone who said :

>
> >>> p.getOutputStream.write((byte)0x3); <---- I want to send a SININT,
> >>> ctrl -c signal, but not working

>
> >> Other than the problems others have mentioned, a byte can get stuck
> >> because you did not flush, or because the input is blocking. You
> >> really need multiple threads to control a child.

>
> >> seehttp://mindprod.com/jgloss/exec.html

>
> > searched around for several days. Java has no ability to send SIGINT
> > to other process

>
> Since SIGINT is OS-specific, that's what you'd expect.


this is very trouble in windows. I can execute a "kill -2" command.
But in windows, cannot.
I need it to make my bochs gui debugger http://code.google.com/p/peter-bochs
to work in windows.
thanks
from Peter
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
The richtextbox not receiving the keys such Ctrl+A, Ctrl+O when typedon it when hosted on web page Gouri.Mahajan7@gmail.com ASP .Net 0 07-11-2008 05:27 AM
Disabling the shortcuts such as Ctrl+A, Ctrl+B.... using Javascript Gouri.Mahajan7@gmail.com ASP .Net 2 07-10-2008 08:15 AM
How to intercept Ctrl key - eg Ctrl E being pressed on Java console program Angus Java 5 11-18-2006 04:19 PM
Implement Ctrl-C, Ctrl-V Danny C++ 5 08-15-2003 03:04 AM
Implement Ctrl-C, Ctrl-V Danny C Programming 5 08-15-2003 03:04 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57