![]() |
ctrl - c not working in pipe
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 (cmk128@hotmail.com) |
Re: ctrl - c not working in pipe
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 |
Re: ctrl - c not working in pipe
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 |
Re: ctrl - c not working in pipe
In article <h6akto$bnf$2@news.albasani.net>, Lew <noone@lewscanon.com>
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> |
Re: ctrl - c not working in pipe
On Sun, 16 Aug 2009 20:44:26 -0700 (PDT), peter <cmk128@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. 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. |
Re: ctrl - c not working in pipe
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 |
Re: ctrl - c not working in pipe
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 |
Re: ctrl - c not working in pipe
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. |
Re: ctrl - c not working in pipe
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 |
| All times are GMT. The time now is 07:56 AM. |
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.