linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* 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: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: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
* 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

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:09 Control-C in bash ??? 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
  -- strict thread matches above, loose matches on Subject: below --
2003-01-13 19:16 Kerl, John
2003-01-13 19:39 ` Mark Chambers
2003-01-13 19:25 Kerl, John
2003-01-13 19:59 Kerl, John

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