@@ -1024,7 +1024,24 @@ static int ctl_get_sigmask(const char __user *buf, int count) {
10241024return retval ;
10251025}
10261026
1027- static ssize_t ctl_write (struct file * file , const char __user * buf ,
1027+
1028+ static int ctl_wait (struct task_struct * task , int start_the_task ) {
1029+ DEFINE_WAIT (wait );
1030+
1031+ printk ("PROCTRACE waiting %d task with %d\n" , task -> pid , current -> pid );
1032+
1033+ if (start_the_task ) {
1034+ wake_up_process (task );
1035+ }
1036+
1037+ prepare_to_wait (& task -> wq_for_stop , & wait , TASK_INTERRUPTIBLE );
1038+ schedule ();
1039+ finish_wait (& task -> wq_for_stop , & wait );
1040+
1041+ return 0 ;
1042+ }
1043+
1044+ static ssize_t ctl_write (struct file * file , const char __user * buf ,
10281045 size_t count , loff_t * ppos )
10291046{
10301047struct task_struct * task = get_proc_task (file -> f_path .dentry -> d_inode );
@@ -1033,10 +1050,14 @@ static ssize_t ctl_write(struct file * file, const char __user *buf,
10331050ctl_waitsignal (task , ctl_get_sigmask (buf + 11 , count - 11 ), 0 );
10341051} else if (strncmp (buf , "startwaitsignal" , 15 ) == 0 ) {
10351052ctl_waitsignal (task , ctl_get_sigmask (buf + 16 , count - 16 ), 1 );
1053+ } else if (strncmp (buf , "startwait" , 9 ) == 0 ) {
1054+ ctl_wait (task , 1 );
10361055} else if (strncmp (buf , "stop" , 4 ) == 0 ) {
10371056ctl_stop (task );
10381057} else if (strncmp (buf , "start" , 5 ) == 0 ) {
10391058ctl_start (task );
1059+ } else if (strncmp (buf , "wait" , 4 ) == 0 ) {
1060+ ctl_wait (task , 0 );
10401061}
10411062
10421063return count ;
0 commit comments