C or ioctl help needed.

Richard A Downing richard at langside.org.uk
Sun Oct 9 09:26:17 PDT 2005


Ken Moffat wrote:
> On Sun, 9 Oct 2005, Richard A Downing wrote:
> 
>>
>> Yes, Google gave me a lot of hits on it too, but I didn't understand a
>> them :-)
>>
> 
>  I don't understand how to find the connection between the ioctl visible
> to the program, and the code that gets called in the kernel, I was
> hoping somebody would jump in.  Of course, I'm assuming that the C
> library (dietlibc, in this case), passes that ioctl to the kernel.
> 
>> Taking your suggestion, I commented the ioctl out.  This produces a
>> working (?) fgetty.  However, I now have the problem that the bash that
>> results from logging in has job control off.  Starts:
>>
>> -bash: job control disabled in this shell
>>
>> I think this is because it's been started without the tty being the
>> controlling tty.
>>
> 
>  Yes.  I didn't mean you to not call the ioctl, just ignore any error
> code (or perhaps call 'logger' to log it on syslog if you are up to it).

In fact this is what I did:

if ((fd=open(tty, O_RDWR, 0))<0 )
  error("could not open tty device\n",3);
ioctl (fd, TIOCSCTTY, (void *1);

>> I also tried mingetty, from which fgetty is derived, and got the same
>> problem - no job control.  And gogetty, same thing.  Clearly there is
>> something here that I don't yet understand.

Mingetty is a 'red herring' - it's the same code. But gogetty runs as
shipped.  They both have the bash job control problem.

> 
>  Does regular agetty provide job control when linked against dietlibc
> (if it can be linked against it) ?  From memory, dietlibc is by far the
> smallest of the C libraries, which means some things have to go.  Sorry
> if you are actually using a full dietlibc system, but it isn't clear
> from this thread.

gogetty uses glibc.  I can try fgetty with glibc, but I'll have to
butcher the makefile - fgetty and dietlibc are from the same guy and he
likes his own libc :-).

I'm pretty sure that util-linux (agetty) can't be linked against
dietlibc since it has no printf. (quoting from it's web page)

Let's see what Felix Leitner has to say, before I start learning how to
write C again (after 20 years off!).

Ken, thanks for the input, it's been instructive.

Richard.



More information about the lfs-chat mailing list