apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jack Andrews <effb...@gmail.com>
Subject poll/select process's IO on windows
Date Tue, 16 Jun 2009 18:42:46 GMT
hi,

i want to detect IO on a child process stdio as well
as a socket from elsewhere.  ie. i want a select()
on /windows/.

is it possible with APR?  or do i have to hack around?

my first attempt is here:

int main(int c,char** argv)
{ apr_procattr_t *attr;
  const char*args[]={"cmd.exe",0};
  apr_sockaddr_t *sa;
  apr_socket_t *sock;
  apr_file_t *fds[4];
  apr_pollfd_t pfd[4],*pfdout;
  apr_pollset_t *pollset;

  fds[0]=(apr_file_t*)sock;
  AS(apr_procattr_create(&attr, pool));
  AS(apr_procattr_io_set(attr, APR_FULL_BLOCK,APR_FULL_BLOCK,APR_FULL_BLOCK));
  AS(apr_procattr_cmdtype_set(attr, APR_PROGRAM));
  AS(apr_proc_create(&newproc, "c:\\Windows\\system32\\cmd.exe", args,
0, attr, pool));
  fds[1]=newproc.in;fds[2]=newproc.out;fds[3]=newproc.err;
  AS(apr_pollset_create(&pollset, 4, pool, APR_POLLSET_WAKEABLE));

#define setpfd(x,a,b,c,d)
pfd[x].desc_type=(a),pfd[x].reqevents=(b),pfd[x].desc.s=(c),pfd[x].client_data=(d)
  for(i=0;i<4;i++)
  { setpfd(i,i?APR_POLL_FILE:APR_POLL_SOCKET,APR_POLLIN|APR_POLLOUT|APR_POLLHUP,(apr_socket_t*)fds[i],NULL);
    AS(apr_pollset_add(pollset,pfd+i));
  }
  for(;APR_TIMEUP==apr_pollset_poll(pollset,0,&n,&pfdout);)
  { printf("hoo\n");
  }
  return 0;
}



ta, jack.

Mime
View raw message