diff --git a/global/max_threads.go b/global/max_threads.go new file mode 100644 index 0000000..ef624c2 --- /dev/null +++ b/global/max_threads.go @@ -0,0 +1,24 @@ +package global + +import ( + "os" + "strconv" + + "github.com/projectdiscovery/utils/sysutil" +) + +const OS_MAX_THREADS_ENV = "OS_MAX_THREADS" + +func init() { + handleOSMaxThreads() +} + +func handleOSMaxThreads() { + osMaxThreads := os.Getenv(OS_MAX_THREADS_ENV) + if osMaxThreads == "" { + return + } + if value, err := strconv.Atoi(osMaxThreads); err == nil && value > 0 { + _ = sysutil.SetMaxThreads(value) + } +}