* RE: Control-C in bash ???
@ 2003-01-13 19:16 Kerl, John
2003-01-13 19:39 ` Mark Chambers
0 siblings, 1 reply; 12+ messages in thread
From: Kerl, John @ 2003-01-13 19:16 UTC (permalink / raw)
To: 'markc@mail.com'; +Cc: 'linuxppc-embedded@lists.linuxppc.org'
This may sound silly, but:
One little gotcha that I ran into was that control-C was being
grabbed by the terminal emulator on my PC. You might try
control-backslash & see if that works. If so, perhaps modify
the emulator's terminal settings.
-----Original Message-----
From: Mark Chambers [mailto:markc@mail.com]
Sent: Monday, January 13, 2003 12:09 PM
To: linuxppc-embedded@lists.linuxppc.org
Subject: Control-C in bash ???
On a PC, I can, for instance, enter "ping 192.168.1.4", then hit Control-C
and stop the ping. For the life of me, I can't figure out how to do the
same on my MPC860 system!!!
I have an MPC860 running 2.4.19, with a mostly unmodified eldk distribution
from Wolfgang Denx. I did modify the init script to use /dev/console
instead
of /ttyx (standard driver using SMC1). I'd not only like a solution, I want
to undertand how cancelling a shell command is supposed to work - I've
poked
around and I can't figure out what's supposed to happen - Does the shell
generate a SIGINT, or the uart driver, or what? Any enlightenment will be
greatly appreciated...
Mark Chambers
markc@mail.com
-------------------------------------------------------
** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/
^ permalink raw reply [flat|nested] 12+ messages in thread
* RE: Control-C in bash ???
@ 2003-01-13 19:59 Kerl, John
0 siblings, 0 replies; 12+ messages in thread
From: Kerl, John @ 2003-01-13 19:59 UTC (permalink / raw)
To: 'Chris Wedgwood', Mark Chambers; +Cc: linuxppc-embedded
Here is some code which is The Wrong Answer (the
right answer being, use Denk's SELF & ELDK and you
will have no worries or problems in life).
Nonetheless, this Wrong Answer is illuminating
in that it shows the essentials of what needs
to happen.
// John Kerl
// Avnet Design Services
// 2002/03/27
// ttyrun.c:
// Runs a program with the terminal set up correctly for job control.
// * Compile with powerpc-linux-gcc ttyrun.c -o ttyrun
// * Run in /etc/rc.whatever as ttyrun {program name} {arguments ...},
// e.g. /bin/ttyrun /bin/sh.
#include <stdio.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <signal.h>
#include <termios.h>
#include <unistd.h>
#include <sys/ioctl.h>
// ----------------------------------------------------------------
void run_prog(int nargc, char ** nargv, char ** oenvp)
{
char * envs[] = {
"HOME=/", "TERM=linux", "PATH=/bin", "LD_LIBRARY_PATH=/lib",
"PS1=temp# ", 0
};
char * nenvp[8];
nenvp[0] = envs[0];
nenvp[1] = envs[1];
nenvp[2] = envs[2];
nenvp[3] = envs[3];
nenvp[4] = envs[4];
nenvp[5] = envs[5];
if (execve(nargv[0], nargv, oenvp) < 0)
perror("execve");
}
// ----------------------------------------------------------------
int main(int argc, char ** argv, char ** envp)
{
char tty_name[] = "/dev/ttyS0";
int tty_fd;
int pid;
int pgrp;
int ppgrp;
int ttypgrp = -2;
if (argc < 2) {
fprintf(stderr, "Usage: %s {program name}\n", argv[0]);
exit(1);
}
tty_fd = open(tty_name, O_RDWR);
if (tty_fd < 0) {
perror("open tty");
exit(1);
}
// Only go through this trouble if the new
// tty doesn't fall in this process group.
pid = getpid();
pgrp = getpgid(0);
ppgrp = getpgid(getppid());
if (ioctl(tty_fd, TIOCGPGRP, &ttypgrp) < 0) {
perror("ioctl TIOCGPGRP");
}
if (pgrp != ttypgrp && ppgrp != ttypgrp) {
if (pid != getsid(0)) {
if (pid == getpgid(0))
setpgid(0, getpgid(getppid()));
setsid();
}
signal(SIGHUP, SIG_IGN);
ioctl(0, TIOCNOTTY, (char *)1);
signal(SIGHUP, SIG_DFL);
close(0);
close(1);
close(2);
close(tty_fd);
tty_fd = open(tty_name, O_RDWR);
ioctl(0, TIOCSCTTY, (char *)1);
dup(tty_fd);
dup(tty_fd);
}
else {
close(tty_fd);
}
run_prog(argc - 1, &argv[1], envp);
return 0;
}
-----Original Message-----
From: Chris Wedgwood [mailto:cw@f00f.org]
Sent: Monday, January 13, 2003 12:49 PM
To: Mark Chambers
Cc: linuxppc-embedded@lists.linuxppc.org
Subject: Re: Control-C in bash ???
On Mon, Jan 13, 2003 at 02:09:00PM -0500, Mark Chambers wrote:
> On a PC, I can, for instance, enter "ping 192.168.1.4", then hit
> Control-C and stop the ping. For the life of me, I can't figure out
> how to do the same on my MPC860 system!!!
if you boot init=/bin/sh or whatever and your init/login doesn't set
the tty up, you will need to do it yourself (man stty).
--cw
** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/
^ permalink raw reply [flat|nested] 12+ messages in thread* RE: Control-C in bash ???
@ 2003-01-13 19:25 Kerl, John
0 siblings, 0 replies; 12+ messages in thread
From: Kerl, John @ 2003-01-13 19:25 UTC (permalink / raw)
To: 'Der Herr Hofrat', markc; +Cc: linuxppc-embedded
This must be a minicom setting (although I can't find it) --
control-C works fine for me in minicom.
-----Original Message-----
From: Der Herr Hofrat [mailto:der.herr@mail.hofr.at]
Sent: Monday, January 13, 2003 12:20 PM
To: markc@mail.com
Cc: linuxppc-embedded@lists.linuxppc.org
Subject: Re: Control-C in bash ???
>
> On a PC, I can, for instance, enter "ping 192.168.1.4", then hit Control-C
> and stop the ping. For the life of me, I can't figure out how to do the
> same on my MPC860 system!!!
>
> I have an MPC860 running 2.4.19, with a mostly unmodified eldk
distribution
> from Wolfgang Denx. I did modify the init script to use /dev/console
instead
> of /ttyx (standard driver using SMC1). I'd not only like a solution, I
want
> to undertand how cancelling a shell command is supposed to work - I've
poked
> around and I can't figure out what's supposed to happen - Does the shell
> generate a SIGINT, or the uart driver, or what? Any enlightenment will be
> greatly appreciated...
I belive that the problem is that the control-C never arives on
the console as the serial-comunication package you are using does
not deliver it (atleast minicom does not) - You can use ping -c 1
(not sure if your ping also takes -c # for the count) to ensure that
it will terminate after one ping package. That was my workaround...
hofrat
** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/
^ permalink raw reply [flat|nested] 12+ messages in thread
* Control-C in bash ???
@ 2003-01-13 19:09 Mark Chambers
2003-01-13 19:20 ` Der Herr Hofrat
` (3 more replies)
0 siblings, 4 replies; 12+ messages in thread
From: Mark Chambers @ 2003-01-13 19:09 UTC (permalink / raw)
To: linuxppc-embedded
On a PC, I can, for instance, enter "ping 192.168.1.4", then hit Control-C
and stop the ping. For the life of me, I can't figure out how to do the
same on my MPC860 system!!!
I have an MPC860 running 2.4.19, with a mostly unmodified eldk distribution
from Wolfgang Denx. I did modify the init script to use /dev/console instead
of /ttyx (standard driver using SMC1). I'd not only like a solution, I want
to undertand how cancelling a shell command is supposed to work - I've poked
around and I can't figure out what's supposed to happen - Does the shell
generate a SIGINT, or the uart driver, or what? Any enlightenment will be
greatly appreciated...
Mark Chambers
markc@mail.com
-------------------------------------------------------
** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/
^ permalink raw reply [flat|nested] 12+ messages in thread* Re: Control-C in bash ???
2003-01-13 19:09 Mark Chambers
@ 2003-01-13 19:20 ` Der Herr Hofrat
2003-01-13 19:30 ` Wolfgang Denk
` (2 subsequent siblings)
3 siblings, 0 replies; 12+ messages in thread
From: Der Herr Hofrat @ 2003-01-13 19:20 UTC (permalink / raw)
To: markc; +Cc: linuxppc-embedded
>
> On a PC, I can, for instance, enter "ping 192.168.1.4", then hit Control-C
> and stop the ping. For the life of me, I can't figure out how to do the
> same on my MPC860 system!!!
>
> I have an MPC860 running 2.4.19, with a mostly unmodified eldk distribution
> from Wolfgang Denx. I did modify the init script to use /dev/console instead
> of /ttyx (standard driver using SMC1). I'd not only like a solution, I want
> to undertand how cancelling a shell command is supposed to work - I've poked
> around and I can't figure out what's supposed to happen - Does the shell
> generate a SIGINT, or the uart driver, or what? Any enlightenment will be
> greatly appreciated...
I belive that the problem is that the control-C never arives on
the console as the serial-comunication package you are using does
not deliver it (atleast minicom does not) - You can use ping -c 1
(not sure if your ping also takes -c # for the count) to ensure that
it will terminate after one ping package. That was my workaround...
hofrat
** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/
^ permalink raw reply [flat|nested] 12+ messages in thread* Re: Control-C in bash ???
2003-01-13 19:09 Mark Chambers
2003-01-13 19:20 ` Der Herr Hofrat
@ 2003-01-13 19:30 ` Wolfgang Denk
2003-01-14 13:44 ` Mark Chambers
2003-01-13 19:48 ` Chris Wedgwood
2003-01-14 13:31 ` Alex Zeffertt
3 siblings, 1 reply; 12+ messages in thread
From: Wolfgang Denk @ 2003-01-13 19:30 UTC (permalink / raw)
To: markc; +Cc: linuxppc-embedded
In message <200301131409.00113.markc@mail.com> you wrote:
>
> I have an MPC860 running 2.4.19, with a mostly unmodified eldk distribution
> from Wolfgang Denx. I did modify the init script to use /dev/console instead
> of /ttyx (standard driver using SMC1). I'd not only like a solution, I want
This is the old ELDK, then? The current version includes
3:2345:respawn:/sbin/mingetty --noclear console
and a fix for the ^C problem....
> to undertand how cancelling a shell command is supposed to work - I've poked
> around and I can't figure out what's supposed to happen - Does the shell
> generate a SIGINT, or the uart driver, or what? Any enlightenment will be
> greatly appreciated...
You need a controlling terminal. We modified login: to set it as
needed. See the previous thread ("RAMDISK IMAGES(2): ash has no job
control").
Best regards,
Wolfgang Denk
--
Software Engineering: Embedded and Realtime Systems, Embedded Linux
Phone: (+49)-8142-4596-87 Fax: (+49)-8142-4596-88 Email: wd@denx.de
"There are three principal ways to lose money: wine, women, and en-
gineers. While the first two are more pleasant, the third is by far
the more certain." -- Baron Rothschild, ca. 1800
** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/
^ permalink raw reply [flat|nested] 12+ messages in thread* Re: Control-C in bash ???
2003-01-13 19:30 ` Wolfgang Denk
@ 2003-01-14 13:44 ` Mark Chambers
0 siblings, 0 replies; 12+ messages in thread
From: Mark Chambers @ 2003-01-14 13:44 UTC (permalink / raw)
To: linuxppc-embedded
Thanks for your help on this one. I changed the last line of etc/inittab to
3:2345:respawn:/sbin/mingetty --noclear tts/0
and added "tts/0" to etc/securetty and now I get a console with job control.
I don't know how long it would have taken me to discover "job control" or "controlling tty"!!
(I'm learning linux from the ground up)
Thanks again,
Mark Chambers
Original message:
> On a PC, I can, for instance, enter "ping 192.168.1.4", then hit Control-C and
> stop the ping. For the life of me, I can't figure out how to do the same on
> my MPC860 system!!!
> I have an MPC860 running 2.4.19, with a mostly unmodified eldk distribution
> from Wolfgang Denx. I did modify the init script to use /dev/console instead
> of /ttyx (standard driver using SMC1). I'd not only like a solution, I want
> to undertand how this works - I've poked around and I can't figure out what's
> supposed to happen - Is the shell that generates a SIGINT, or the uart
> driver, or what? Any enlightenment will be greatly appreciated...
** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Control-C in bash ???
2003-01-13 19:09 Mark Chambers
2003-01-13 19:20 ` Der Herr Hofrat
2003-01-13 19:30 ` Wolfgang Denk
@ 2003-01-13 19:48 ` Chris Wedgwood
2003-01-14 13:31 ` Alex Zeffertt
3 siblings, 0 replies; 12+ messages in thread
From: Chris Wedgwood @ 2003-01-13 19:48 UTC (permalink / raw)
To: Mark Chambers; +Cc: linuxppc-embedded
On Mon, Jan 13, 2003 at 02:09:00PM -0500, Mark Chambers wrote:
> On a PC, I can, for instance, enter "ping 192.168.1.4", then hit
> Control-C and stop the ping. For the life of me, I can't figure out
> how to do the same on my MPC860 system!!!
if you boot init=/bin/sh or whatever and your init/login doesn't set
the tty up, you will need to do it yourself (man stty).
--cw
** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Control-C in bash ???
2003-01-13 19:09 Mark Chambers
` (2 preceding siblings ...)
2003-01-13 19:48 ` Chris Wedgwood
@ 2003-01-14 13:31 ` Alex Zeffertt
2003-01-14 14:50 ` Wolfgang Denk
2003-01-14 14:51 ` Dan Malek
3 siblings, 2 replies; 12+ messages in thread
From: Alex Zeffertt @ 2003-01-14 13:31 UTC (permalink / raw)
To: markc; +Cc: linuxppc-embedded@lists.linuxppc.org
Hi Mark,
I had exactly the same problem with ash (busybox version), but I found
it went away when I replaced
ttyS0::respawn:-/bin/sh
in /etc/inittab with
ttyS0::respawn:/sbin/login
I have no idea why....
Alex
On Mon, 2003-01-13 at 19:09, Mark Chambers wrote:
>
> On a PC, I can, for instance, enter "ping 192.168.1.4", then hit Control-C
> and stop the ping. For the life of me, I can't figure out how to do the
> same on my MPC860 system!!!
>
> I have an MPC860 running 2.4.19, with a mostly unmodified eldk distribution
> from Wolfgang Denx. I did modify the init script to use /dev/console instead
> of /ttyx (standard driver using SMC1). I'd not only like a solution, I want
> to undertand how cancelling a shell command is supposed to work - I've poked
> around and I can't figure out what's supposed to happen - Does the shell
> generate a SIGINT, or the uart driver, or what? Any enlightenment will be
> greatly appreciated...
>
> Mark Chambers
> markc@mail.com
>
> -------------------------------------------------------
>
>
>
** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/
^ permalink raw reply [flat|nested] 12+ messages in thread* Re: Control-C in bash ???
2003-01-14 13:31 ` Alex Zeffertt
@ 2003-01-14 14:50 ` Wolfgang Denk
2003-01-14 14:51 ` Dan Malek
1 sibling, 0 replies; 12+ messages in thread
From: Wolfgang Denk @ 2003-01-14 14:50 UTC (permalink / raw)
To: Alex Zeffertt; +Cc: markc, linuxppc-embedded@lists.linuxppc.org
In message <1042551106.8605.109.camel@zambia> you wrote:
>
> I had exactly the same problem with ash (busybox version), but I found
> it went away when I replaced
>
> ttyS0::respawn:-/bin/sh
>
> in /etc/inittab with
>
> ttyS0::respawn:/sbin/login
>
> I have no idea why....
I explained this a couple of times before on the list:
Signal handling depends on a controlling tty. If you start a shell
directly, you don't get one, so ^C will not work.
We modified the login in our ELDK a bit to assign a controlling tty,
so any shell started from login will behave as expected.
This is all the magic that it takes:
-> cat /opt/eldk/build/target_rpms/util-linux/SOURCES/login-eldk.patch
--- util-linux-2.11f/login-utils/login.c.orig Fri Jun 21 14:17:36 2002
+++ util-linux-2.11f/login-utils/login.c Fri Jun 21 14:18:34 2002
@@ -259,6 +259,7 @@
flags &= ~O_NONBLOCK;
fcntl(fd, F_SETFL, flags);
+ ioctl(fd, TIOCSCTTY);
for (i = 0 ; i < fd ; i++)
close(i);
Best regards,
Wolfgang Denk
--
Software Engineering: Embedded and Realtime Systems, Embedded Linux
Phone: (+49)-8142-4596-87 Fax: (+49)-8142-4596-88 Email: wd@denx.de
"Free markets select for winning solutions." - Eric S. Raymond
** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/
^ permalink raw reply [flat|nested] 12+ messages in thread* Re: Control-C in bash ???
2003-01-14 13:31 ` Alex Zeffertt
2003-01-14 14:50 ` Wolfgang Denk
@ 2003-01-14 14:51 ` Dan Malek
1 sibling, 0 replies; 12+ messages in thread
From: Dan Malek @ 2003-01-14 14:51 UTC (permalink / raw)
To: Alex Zeffertt; +Cc: markc, linuxppc-embedded@lists.linuxppc.org
Alex Zeffertt wrote:
> I had exactly the same problem with ash (busybox version), but I found
> it went away when I replaced
>
> ttyS0::respawn:-/bin/sh
>
> in /etc/inittab with
>
> ttyS0::respawn:/sbin/login
>
> I have no idea why....
If all of you would look back into the mailing list archives you would
notice this discussion before. The reason ctl-C won't work is you need
a "controlling tty" device.
The program that is started as process ID 1 is a special program (expected
to be '/sbin/init') and can't be used as a 'controlling tty'. Signals to
this process are managed differently in the kernel. Any program you start
in this process ID slot, which is you favorite shell or busybox or whatever,
can't assign a controlling tty and get the ctl-C signals. It doesn't matter
how it is built or what ioctls you try to send to the driver.
If you start up init, or run /bin/login or any of a variety of things you
can do to actually configure a controlling tty and spawn a shell will
obivously work as expected. Starting up a shell as 'init=/bin/sh', or some
other program in the 'init' PID 1 slot is considered a recovery method and
will lose some of its tty functions. Even for a shell not in the PID 1 slot,
you have to do something along the path to configure a driver as a "controlling
tty", using /bin/login or the methods Wolfgang described in past messages.
Thanks.
-- Dan
** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2003-01-14 14:51 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-01-13 19:16 Control-C in bash ??? Kerl, John
2003-01-13 19:39 ` Mark Chambers
-- strict thread matches above, loose matches on Subject: below --
2003-01-13 19:59 Kerl, John
2003-01-13 19:25 Kerl, John
2003-01-13 19:09 Mark Chambers
2003-01-13 19:20 ` Der Herr Hofrat
2003-01-13 19:30 ` Wolfgang Denk
2003-01-14 13:44 ` Mark Chambers
2003-01-13 19:48 ` Chris Wedgwood
2003-01-14 13:31 ` Alex Zeffertt
2003-01-14 14:50 ` Wolfgang Denk
2003-01-14 14:51 ` Dan Malek
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).