![]() Chapter Contents  | 
![]() Previous  | 
![]() Next  | 
| w_ioctl | 
| Portability: | SAS/C extension | 
| SYNOPSIS | |
| DESCRIPTION | |
| RETURN VALUE | |
| PORTABILITY | |
| EXAMPLE | |
| RELATED FUNCTIONS | 
| SYNOPSIS | 
#include <termios.h>
 int w_ioctl(int fileDescriptor, int command, int argLength,
             void *argBuffer);
| DESCRIPTION | 
w_ioctl
 enables you to pass device-specific commands and arguments
to an I/O device driver. 
w_ioctl
 accepts the following arguments:
fileDescriptor
command
argLength
arg
 argument. The minimum length
is 1 and maximum length is 1024.
argBuffer
| RETURN VALUE | 
w_ioctl
 returns a 
0
if successful and a 
-1
if unsuccessful.
| PORTABILITY | 
The 
w_ioctl
 function may be useful in USS applications; however, it is
not defined by the POSIX.1 standard and should not be used in portable applications.
| EXAMPLE | 
The following example illustrates the
use of 
w_ioctl
 to pass
a command to the controlling terminal: 
#include <sys/types.h>
#include <stdio.h>
#include <unistd.h>
#define MAX_CHAR 256
main()
{
   int processNum = 0;
   W_PSPROC workArea;
      /* Initialize work area.                   */
   memset(&workArea, 0, sizeof(workArea));
      /* Allocate memory for character strings.  */
   if ((workArea.ps_conttyptr = (char *) malloc(MAX_CHAR)) == NULL) {
      perror("ps_conttyptr memory allocation error");
      abort();
   }
   else
      workArea.ps_conttylen = MAX_CHAR;
   if ((workArea.ps_pathptr = (char *) malloc(MAX_CHAR)) == NULL) {
      perror("ps_pathptr memory allocation error");
      abort();
   }
   else
      workArea.ps_pathlen = MAX_CHAR;
   if ((workArea.ps_cmdptr = (char *) malloc(MAX_CHAR)) == NULL) {
      perror("ps_cmdptr memory allocation error");
      abort();
   }
   else
      workArea.ps_cmdlen = MAX_CHAR;
      /* Get process information.                */
   do {
      processNum = w_getpsent(processNum, &workArea, sizeof(workArea));
      if (processNum == -1)
           perror("error in w_getpsent");
      else  {
         printf("process number = %dn", processNum);
         printf("process ID = %10dn", workArea.ps_pid);
         printf("User ID = %8unn", workArea.ps_ruid);
      }
   } while (processNum != 0 && processNum != 1);
}
| RELATED FUNCTIONS | 
tcdrain
, 
tcflow
, 
tcflush
, 
tcsendbreak
![]() Chapter Contents  | 
![]() Previous  | 
![]() Next  | 
![]() Top of Page  | 
Copyright © 2001 by SAS Institute Inc., Cary, NC, USA. All rights reserved.