@@ -44,27 +44,39 @@ sigset_t orig_mask;
4444static int hyper_handle_exit (struct hyper_pod * pod );
4545static int hyper_ctl_append_msg (struct hyper_event * he , uint32_t type , uint8_t * data , uint32_t len );
4646
47- static int hyper_set_win_size (char * json , int length )
47+ static int hyper_set_win_size (struct hyper_pod * pod , char * json , int length )
4848{
4949 struct winsize size ;
5050 struct hyper_exec * exec ;
51- int ret ;
51+ int ret = -1 ;
5252
53- fprintf (stdout , "call hyper_win_size , json %s, len %d\n" , json , length );
53+ fprintf (stdout , "call hyper_set_win_size , json %s, len %d\n" , json , length );
5454 JSON_Value * value = hyper_json_parse (json , length );
5555 if (value == NULL ) {
5656 fprintf (stderr , "set term size failed\n" );
57- ret = -1 ;
5857 goto out ;
5958 }
60- const uint64_t seq = (uint64_t )json_object_get_number (json_object (value ), "seq" );
59+ const char * container = json_object_get_string (json_object (value ), "container" );
60+ const char * process = json_object_get_string (json_object (value ), "process" );
61+ if (!container || !process ) {
62+ fprintf (stderr , "call hyper_set_win_size, invalid config" );
63+ goto out ;
64+ }
6165
62- exec = hyper_find_exec_by_seq (& global_pod , seq );
63- if (exec == NULL ) {
64- fprintf (stdout , "can not find exec whose seq is %" PRIu64 "\n" , seq );
65- ret = 0 ;
66+ struct hyper_container * c = hyper_find_container (pod , container );
67+ if (!c ) {
68+ fprintf (stderr , "call hyper_set_win_size, can not find the container: %s\n" , container );
6669 goto out ;
6770 }
71+ if (strcmp (c -> exec .id , process ) == 0 ) {
72+ exec = & c -> exec ;
73+ } else {
74+ exec = hyper_find_exec_by_name (pod , process );
75+ if (!exec ) {
76+ fprintf (stderr , "call hyper_set_win_size, can not find the process: %s\n" , process );
77+ goto out ;
78+ }
79+ }
6880
6981 size .ws_row = (int )json_object_get_number (json_object (value ), "row" );
7082 size .ws_col = (int )json_object_get_number (json_object (value ), "column" );
@@ -1117,7 +1129,7 @@ static int hyper_ctlmsg_handle(struct hyper_event *he, uint32_t len)
11171129 ret = hyper_rescan ();
11181130 break ;
11191131 case WINSIZE :
1120- ret = hyper_set_win_size ((char * )buf -> data + 8 , len - 8 );
1132+ ret = hyper_set_win_size (pod , (char * )buf -> data + 8 , len - 8 );
11211133 break ;
11221134 case NEWCONTAINER :
11231135 ret = hyper_new_container ((char * )buf -> data + 8 , len - 8 );
0 commit comments