Skip to content

Commit

Permalink
Merge pull request #572 from projectdiscovery/add_max_thread_env_var
Browse files Browse the repository at this point in the history
add global `OS_MAX_THREADS` env variable
  • Loading branch information
Mzack9999 authored Nov 26, 2024
2 parents af7d763 + 6bcddac commit 70cf636
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions global/max_threads.go
Original file line number Diff line number Diff line change
@@ -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)
}
}

0 comments on commit 70cf636

Please sign in to comment.