ctrl - c not working in pipe

P

peter

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 ([email protected])
 
L

Lew

peter said:
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.
 
L

Lew

Lew said:
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.
 
J

John B. Matthews

[QUOTE="Lew said:
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.[/QUOTE]

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.
 
P

peter

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. Even in visual c++, no way to do it too.
thanks
from Peter
 
L

Lew

peter said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top