www.delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/1998/05/21/07:06:47

From: davidav AT msil DOT sps DOT mot DOT com (David Avrahamov)
Subject: The IOCTL system call !
21 May 1998 07:06:47 -0700 :
Message-ID: <35629781.AF9824FC.cygnus.gnu-win32@msil.sps.mot.com>
Mime-Version: 1.0
To: gnu-win32 AT cygnus DOT com
Cc: davidav <davidav AT msil DOT sps DOT mot DOT com>

--------------6E1F0E94C42C95831CCE2287
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Hi everybody,

I have been using the CYGNUS development environment lately on WinNT 4.0 .
It seems to be working great except for the following thing.
The ioctl system call doesn't work for me.
Here is a simple code which uses ioctl and runs perfectly on SUN-OS:

#include <stdio.h>
#ifdef SUN
#include <sys/filio.h>
#else
#include <asm/socket.h>
#endif
#include <errno.h>
#include <termio.h>

main()
{
    int os_status=0;
    int fd=0;
    unsigned long i=0;
    char str[200];

    printf("print something !\n");
    while(1){
        os_status = ioctl (fd, FIONREAD, &i);
        if (os_status == -1){
            printf("i=%d  os_status=%d\n",i,os_status);
            printf("errno = %d\n",errno);
            exit (1);
        }
        if (i){
            scanf("%s",str);
            if (!strcmp(str,":q"))
                exit(0);
            printf("You wrote: %s\n",str);
        }
    }
}

This code uses ioctl in order to verify whether there is an input before
actualy trying to read. This avoids the program from blocking.

I have already tried the update version of cygwinb19.dll
(new-cygwinb19.dll.gz) but I am getting a memory access violation even
when I try to compile.

I am really looking forward for your suggestions.
Thank you very much,

--
David Avrahamov
Phone number: 952-2176
Software department
Motorola Semiconductor Israel



--------------6E1F0E94C42C95831CCE2287
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<HTML>

<PRE>
Hi everybody,

I have been using the CYGNUS development environment lately on WinNT 4.0 .
It seems to be working great except for the following thing.
The ioctl system call doesn't work for me.
Here is a simple code which uses ioctl and runs perfectly on SUN-OS:

#include &lt;stdio.h>
#ifdef SUN
#include &lt;sys/filio.h>
#else
#include &lt;asm/socket.h>
#endif
#include &lt;errno.h>
#include &lt;termio.h>

main()
{
&nbsp;&nbsp;&nbsp; int os_status=0;
&nbsp;&nbsp;&nbsp; int fd=0;
&nbsp;&nbsp;&nbsp; unsigned long i=0;
&nbsp;&nbsp;&nbsp; char str[200];

&nbsp;&nbsp;&nbsp; printf("print something !\n");
&nbsp;&nbsp;&nbsp; while(1){
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; os_status = ioctl (fd, FIONREAD, &amp;i);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (os_status == -1){
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("i=%d&nbsp; os_status=%d\n",i,os_status);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("errno = %d\n",errno);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; exit (1);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (i){
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; scanf("%s",str);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (!strcmp(str,":q"))
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; exit(0);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("You wrote: %s\n",str);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }
&nbsp;&nbsp;&nbsp; }
}

This code uses ioctl in order to verify whether there is an input before&nbsp;
actualy trying to read. This avoids the program from blocking.

I have already tried the update version of cygwinb19.dll
(new-cygwinb19.dll.gz) but I am getting a memory access violation even&nbsp;
when I try to compile.

I am really looking forward for your suggestions.
Thank you very much,


--&nbsp;
David Avrahamov&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
Phone number: 952-2176
Software department
Motorola Semiconductor Israel</PRE>
&nbsp;</HTML>

--------------6E1F0E94C42C95831CCE2287--

-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request AT cygnus DOT com" with one line of text: "help".

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019