Exemplo n.º 1
0
static void DoTasks(int fd)
{
	int
		processID;

	processID=fork();
	if(processID>=0)
	{
		if(processID)				// =0 for the child, =PID of the child for the parent
		{
			WriteDevice(TTYIN,fd);	// will run until done=true
			if(kill(processID,SIGKILL)<0)
			{
				ReportString(REPORT_ERROR,"terminal: failed to kill sub-task\n");
			}
		}
		else
		{
			ReadDevice(fd,TTYOUT);		// child task, will run until done=true
		}
	}
	else
	{
		ReportString(REPORT_ERROR,"terminal: failed to fork\n");
	}
}
Exemplo n.º 2
0
int IsBusy(libusb_device_handle *alienfx, int *is_busy_return)
/*:note: The is_busy_return should be set to 1 if the device is busy,
 *       but hasn't yet been implemented.
 */
{
    int succp = 0;
	int read_bytes = 0;
	unsigned char data[] = { START_BYTE, COMMAND_GET_STATUS };
    unsigned char data_input[READ_DATA_SIZE];

	read_bytes = ReadDevice(alienfx, &data_input[0], READ_DATA_SIZE);
    if(0 < read_bytes) {
        succp = (START_BYTE == data_input[0]);
    } else {
		if(LIBUSB_ERROR_BUSY == read_bytes)
			*is_busy_return = 1;
        fprintf(stderr, "ReadDevice: failed to read any bytes: %s\n",
                strerror(errno));
    }
    return succp;
}