linux kernel - interacting user space during system call -
i'm trying write block device driver implements read/write operations. tricky thing information not in hardware, in user space process. therefore, during read/write system call interact user space (i.e. sendign signal user space). however, user space process catching signal after read/write system call returned. adding wait in system call implementation seems ignored somehow.
i used code @ read system call:
ssize_t sleepy_read(struct file *filp, char *buf, size_t count, loff_t *f_pos) { struct siginfo info; struct task_struct *t; int ret; #define sig_test 44 memset(&info, 0, sizeof(struct siginfo)); info.si_signo = sig_test; info.si_code = si_queue; info.si_int = 1234; rcu_read_lock(); t = pid_task(find_pid_ns(current->pid, &init_pid_ns), pidtype_pid); if(t == null){ printk(kern_err "no such pid\n"); rcu_read_unlock(); return -enodev; } rcu_read_unlock(); ret = send_sig_info(sig_test, &info, t); //send signal if (ret < 0) { printk("error sending signal\n"); return ret; } wait_event_interruptible(wq, flag != 0); msleep(10000); return (0); }
and code @ user space:
#define sig_test 44 int g_devfile = -1; void receivedata(int n, siginfo_t *info, void *unused) { printf("received value %i\n", info->si_int); } int main(void) { struct sigaction sig; sig.sa_sigaction = receivedata; sig.sa_flags = sa_siginfo; sigaction(sig_test, &sig, null); g_devfile = open(devname, o_rdwr); if ( g_devfile < 0 ) { fprintf(stderr,"error opening device[%s] file err[%s]\n",devname,strerror(errno)); return -1; } else { fprintf (stderr, "device opened. ptr=%p\n", (void*)g_devfile); } = read(g_devfile, &buff, 11); }
currently i'm catching signal (in user space) after 10 seconds sleep expieres (the wait seems ignored). idea appriceated. thanks.
Comments
Post a Comment