@@ -5002,6 +5002,8 @@ static job_T *first_job = NULL;
50025002 static void
50035003job_free_contents (job_T * job )
50045004{
5005+ int i ;
5006+
50055007 ch_log (job -> jv_channel , "Freeing job" );
50065008 if (job -> jv_channel != NULL )
50075009 {
@@ -5019,6 +5021,12 @@ job_free_contents(job_T *job)
50195021 vim_free (job -> jv_tty_out );
50205022 vim_free (job -> jv_stoponexit );
50215023 free_callback (job -> jv_exit_cb , job -> jv_exit_partial );
5024+ if (job -> argv != NULL )
5025+ {
5026+ for (i = 0 ; job -> argv [i ] != NULL ; i ++ )
5027+ vim_free (job -> argv [i ]);
5028+ vim_free (job -> argv );
5029+ }
50225030}
50235031
50245032 static void
@@ -5463,6 +5471,8 @@ job_start(typval_T *argvars, char **argv_arg, jobopt_T *opt_arg)
54635471#endif
54645472 jobopt_T opt ;
54655473 ch_part_T part ;
5474+ int len ;
5475+ int i ;
54665476
54675477 job = job_alloc ();
54685478 if (job == NULL )
@@ -5593,11 +5603,21 @@ job_start(typval_T *argvars, char **argv_arg, jobopt_T *opt_arg)
55935603#endif
55945604 }
55955605
5606+ /* Save the command used to start the job */
5607+ len = 0 ;
5608+ for (i = 0 ; argv [i ] != NULL ; i ++ )
5609+ len ++ ;
5610+ job -> argv = (char_u * * )alloc (sizeof (char_u * ) * (len + 1 ));
5611+ if (job -> argv == NULL )
5612+ goto theend ;
5613+ for (i = 0 ; argv [i ] != NULL ; i ++ )
5614+ job -> argv [i ] = vim_strsave ((char_u * )argv [i ]);
5615+ job -> argv [i ] = NULL ;
5616+
55965617#ifdef USE_ARGV
55975618 if (ch_log_active ())
55985619 {
55995620 garray_T ga ;
5600- int i ;
56015621
56025622 ga_init2 (& ga , (int )sizeof (char ), 200 );
56035623 for (i = 0 ; i < argc ; ++ i )
@@ -5661,6 +5681,8 @@ job_info(job_T *job, dict_T *dict)
56615681{
56625682 dictitem_T * item ;
56635683 varnumber_T nr ;
5684+ list_T * l ;
5685+ int i ;
56645686
56655687 dict_add_nr_str (dict , "status" , 0L , (char_u * )job_status (job ));
56665688
@@ -5689,6 +5711,33 @@ job_info(job_T *job, dict_T *dict)
56895711 dict_add_nr_str (dict , "exitval" , job -> jv_exitval , NULL );
56905712 dict_add_nr_str (dict , "exit_cb" , 0L , job -> jv_exit_cb );
56915713 dict_add_nr_str (dict , "stoponexit" , 0L , job -> jv_stoponexit );
5714+
5715+ l = list_alloc ();
5716+ if (l != NULL )
5717+ {
5718+ dict_add_list (dict , "cmd" , l );
5719+ for (i = 0 ; job -> argv [i ] != NULL ; i ++ )
5720+ list_append_string (l , job -> argv [i ], -1 );
5721+ }
5722+ }
5723+
5724+ /*
5725+ * Implementation of job_info() to return info for all jobs.
5726+ */
5727+ void
5728+ job_info_all (list_T * l )
5729+ {
5730+ job_T * job ;
5731+ typval_T tv ;
5732+
5733+ for (job = first_job ; job != NULL ; job = job -> jv_next )
5734+ {
5735+ tv .v_type = VAR_JOB ;
5736+ tv .vval .v_job = job ;
5737+
5738+ if (list_append_tv (l , & tv ) != OK )
5739+ return ;
5740+ }
56925741}
56935742
56945743/*
0 commit comments