fd_set rfds; // globally defined structure for file descriptor select
int fd0;
int fd1;

int openfifo() {
  fd0 = open("/dev/pwm0", O_RDWR | O_SYNC); // open fifo for reading
  fd1 = open("/dev/pwm1", O_RDWR | O_SYNC);
  if( fd0 == -1 ) { perror("open");exit(1); }
  if( fd1 == -1 ) { perror("open");exit(1); }
...
int readfromfifo(int *whichservo) { // returns whichservo and value of servo
...
  FD_ZERO(&rfds);
  FD_SET(fd0, &rfds);
  FD_SET(fd1, &rfds);
  select( max(fd0, fd1)+1, &rfds, NULL, NULL, NULL);
...
  if (FD_ISSET(fd0, &rfds)) {
    read( fd0, &buffer, 1);
    *whichservo=0;
    printf("servo %d got some data\n", *whichservo);
}
  if (FD_ISSET(fd1, &rfds)) {
    read( fd1, &buffer, 1);
    *whichservo=1;
    printf("servo %d got some data\n", *whichservo);
  }
...
  // connect to the ssc
  if(ssc_open(port,baudrate)) perror("failed to open serial port");
  openfifo(); // global variable istead of return
  while (1) {
    x_in = readfromfifo(&servo); // servo number and x_in returned from function
...
    ssc_move( servo, x_in  );