@@ -623,8 +623,13 @@ 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:
628+ // default threads = -1 (== "auto")
629+ long nthreads = -1 ;
630+ // interactive threads = 1, or 0 if generating output
631+ long nthreadsi = jl_generating_output () ? 0 : 1 ;
632+
628633 if (!strncmp (optarg , "auto" , 4 )) {
629634 jl_options .nthreads = -1 ;
630635 if (optarg [4 ] == ',' ) {
@@ -633,10 +638,9 @@ JL_DLLEXPORT void jl_parse_opts(int *argcp, char ***argvp)
633638 else {
634639 errno = 0 ;
635640 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 " );
641+ if (errno != 0 || endptr == & optarg [5 ] || * endptr != 0 || nthreadsi < 0 || nthreadsi >= INT16_MAX )
642+ jl_errorf ("julia: -t,--threads=auto,<m>; m must be an integer >= 0 " );
638643 }
639- jl_options .nthreadpools ++ ;
640644 }
641645 }
642646 else {
@@ -650,17 +654,18 @@ JL_DLLEXPORT void jl_parse_opts(int *argcp, char ***argvp)
650654 errno = 0 ;
651655 char * endptri ;
652656 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" );
657+ // Allow 0 for interactive
658+ if (errno != 0 || endptri == & endptr [1 ] || * endptri != 0 || nthreadsi < 0 || nthreadsi >= INT16_MAX )
659+ jl_errorf ("julia: -t,--threads=<n>,<m>; m must be an integer ≥ 0" );
660+ if (nthreadsi == 0 )
661+ jl_options .nthreadpools = 1 ;
655662 }
656- jl_options .nthreadpools ++ ;
657663 }
658664 jl_options .nthreads = nthreads + nthreadsi ;
659665 }
660666 int16_t * ntpp = (int16_t * )malloc_s (jl_options .nthreadpools * sizeof (int16_t ));
661667 ntpp [0 ] = (int16_t )nthreads ;
662- if (jl_options .nthreadpools == 2 )
663- ntpp [1 ] = (int16_t )nthreadsi ;
668+ ntpp [1 ] = (int16_t )nthreadsi ;
664669 jl_options .nthreads_per_pool = ntpp ;
665670 break ;
666671 case 'p' : // procs
0 commit comments