Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Redirecting shell's I/O to a hole in the ground

481 views
Skip to first unread message

Pete Cook

unread,
Apr 22, 1999, 3:00:00 AM4/22/99
to
I'm trying to redirect the shell's I/O to a hole in the ground, somewhat
like /dev/null.

I know about the function shellOrigStdSet(), but what could I use for the
"fd" parameter?

I don't want to delete the shell task, as I want to be able to connect to it
from afar.

Any help would be much appreciated,

Pete.

Robert Armstrong

unread,
Apr 23, 1999, 3:00:00 AM4/23/99
to
Couple of things you might try, probably the simplest is to tell it the
console port is NONE... no local i/o what so ever. Go into config.h and add
the following line somewhere after configAll.h get's included (we aren't using
configdb.h are we? hoped not).

#define CONSOLE_TTY NONE

This will ignore everything, including ctrl-x.


Alternatively open /dev/null and use ioGlobalStdSet() to fire stdin, stdout
and stderr down the hole :)

Something like:-

int fd = open("/dev/null",3);
ioGlobalStdSet(0,fd);
ioGlobalStdSet(1,fd);
ioGlobalStdSet(2,fd);


I'd try the first option by preference.

HTH,
Bob

In article <371f4...@nnrp1.news.uk.psi.net>, "Pete Cook"

Charles H. Chapman

unread,
Apr 23, 1999, 3:00:00 AM4/23/99
to
On Fri, 23 Apr 1999 07:23:38 GMT, Robert Armstrong <bobarm...@home.net>
wrote:

>
>Alternatively open /dev/null and use ioGlobalStdSet() to fire stdin, stdout
>and stderr down the hole :)
>
>Something like:-
>
> int fd = open("/dev/null",3);
> ioGlobalStdSet(0,fd);
> ioGlobalStdSet(1,fd);
> ioGlobalStdSet(2,fd);

Don't you mean /null rather than /dev/null? I have no /dev/null on
my system.

Chuck

Robert Armstrong

unread,
Apr 23, 1999, 3:00:00 AM4/23/99
to
It was late, there was a fire, the dog ate my homework, my grandmother died,
there was an earthquake, a typhoon... OK, guilty. Too much UNIX in that file
system.

Bob

In article <slrn7i0pi...@nasa2.ksc.nasa.gov>, c...@nasa2.ksc.nasa.gov

Jim Wiggins

unread,
Apr 27, 1999, 3:00:00 AM4/27/99
to

this code seems to work well for me:

static void
beSilent(void)
{
/* redirect all this task's output to the bit bucket */
ioTaskStdSet(0, 1, -1);
ioTaskStdSet(0, 2, -1);
return;
}

static void
youMaySpeakNow(void)
{
/* return output to normal */
ioctl(1, FIOFLUSH, 0);
ioctl(2, FIOFLUSH, 0);
ioTaskStdSet(0, 1, 1);
ioTaskStdSet(0, 2, 2);
return;
}

-jw
--
Jim Wiggins - Contracted to Inter-Tel

Ian Love

unread,
May 7, 1999, 3:00:00 AM5/7/99
to Pete Cook
Pete Cook wrote:
>
> I'm trying to redirect the shell's I/O to a hole in the ground, somewhat
> like /dev/null.
>
> I know about the function shellOrigStdSet(), but what could I use for the
> "fd" parameter?
>
> I don't want to delete the shell task, as I want to be able to connect to it
> from afar.
>
> Any help would be much appreciated,
>
> Pete.

We have added password security to our console, and task locking :
this required pulling the shell away from the console (as above).
Unfortunately the null device isn't very good at handling the 'In' bit-
I believe it returns instantly with an error - which is not what you
really want to be doing... (making the shell - priority 1 - spin!!!)
In combination with shellLock(), shellLogoutInstall, shellRestart() etc
you can then implement console shell security or whatever else you
require...


So...

write yourself a device driver that for 'write' operations returns
instantly with OK, and a read operation that just hangs.
Code fragments follow [including complete 'empty' driver
implementation]:

#define EMPTY_CONSOLE_DEV "/empty"

int emptyFd=open(EMPTY_CONSOLE_DEV,O_RDWR,0);

/* move STD_IN/OUT/ERR to an empty TTY device */
ioGlobalStdSet(STD_IN, emptyFd);
ioGlobalStdSet(STD_OUT, emptyFd);
ioGlobalStdSet(STD_ERR, emptyFd);

/* the EMPTY Device driver */
static int emptyRead(DEV_HDR *hdr,char *buf, int len)
{
taskSuspend(0);
return 0;
}

static int emptyWrite(DEV_HDR *hdr,char *buf, int len)
{
return len;
}

int createEmptyDev(void)
{
static DEV_HDR hdr;

int drvnum=iosDrvInstall(0,0,0,0,
(FUNCPTR)emptyRead,(FUNCPTR)emptyWrite,
0);

if(drvnum==ERROR)
return ERROR;

return iosDevAdd(&hdr,EMPTY_CONSOLE_DEV,drvnum);
}

sorry, but I can't post the rest of the shell security code :-(
- but its not that hard to completely replace the standard stuff with
your own code - we've got security around the bootline as well on
console and remote access.

HTH
regards
Ian Love,

The views expressed above are my own and not those of my employer

0 new messages