@@ -623,8 +623,10 @@ JL_DLLEXPORT void jl_parse_opts(int *argcp, char ***argvp)
623623 break ;
624624 case 't' : // threads
625625 errno = 0 ;
626- jl_options .nthreadpools = 1 ;
627- long nthreads = -1 , nthreadsi = 0 ;
626+ jl_options .nthreadpools = 2 ;
627+ // By default, main threads = -1 (== "auto"), interactive = 1
628+ long nthreads = -1 , nthreadsi = 1 ;
629+
628630 if (!strncmp (optarg , "auto" , 4 )) {
629631 jl_options .nthreads = -1 ;
630632 if (optarg [4 ] == ',' ) {
@@ -633,10 +635,9 @@ JL_DLLEXPORT void jl_parse_opts(int *argcp, char ***argvp)
633635 else {
634636 errno = 0 ;
635637 nthreadsi = strtol (& optarg [5 ], & endptr , 10 );
636- if (errno != 0 || endptr == & optarg [5 ] || * endptr != 0 || nthreadsi < 1 || nthreadsi >= INT16_MAX )
637- jl_errorf ("julia: -t,--threads=auto,<m>; m must be an integer >= 1 " );
638+ if (errno != 0 || endptr == & optarg [5 ] || * endptr != 0 || nthreadsi < 0 || nthreadsi >= INT16_MAX )
639+ jl_errorf ("julia: -t,--threads=auto,<m>; m must be an integer >= 0 " );
638640 }
639- jl_options .nthreadpools ++ ;
640641 }
641642 }
642643 else {
@@ -650,17 +651,16 @@ JL_DLLEXPORT void jl_parse_opts(int *argcp, char ***argvp)
650651 errno = 0 ;
651652 char * endptri ;
652653 nthreadsi = strtol (& endptr [1 ], & endptri , 10 );
653- if (errno != 0 || endptri == & endptr [1 ] || * endptri != 0 || nthreadsi < 1 || nthreadsi >= INT16_MAX )
654- jl_errorf ("julia: -t,--threads=<n>,<m>; n and m must be integers >= 1" );
654+ // Allow 0 for interactive
655+ if (errno != 0 || endptri == & endptr [1 ] || * endptri != 0 || nthreadsi < 0 || nthreadsi >= INT16_MAX )
656+ jl_errorf ("julia: -t,--threads=<n>,<m>; m must be an integer ≥ 0" );
655657 }
656- jl_options .nthreadpools ++ ;
657658 }
658659 jl_options .nthreads = nthreads + nthreadsi ;
659660 }
660661 int16_t * ntpp = (int16_t * )malloc_s (jl_options .nthreadpools * sizeof (int16_t ));
661662 ntpp [0 ] = (int16_t )nthreads ;
662- if (jl_options .nthreadpools == 2 )
663- ntpp [1 ] = (int16_t )nthreadsi ;
663+ ntpp [1 ] = (int16_t )nthreadsi ;
664664 jl_options .nthreads_per_pool = ntpp ;
665665 break ;
666666 case 'p' : // procs
0 commit comments