Skip to content

Commit

Permalink
Make setUlimit a noop on Windows.
Browse files Browse the repository at this point in the history
  • Loading branch information
jchv committed Oct 7, 2018
1 parent d0df152 commit 31fffd0
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 22 deletions.
2 changes: 2 additions & 0 deletions ibazel/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ go_library(
"ibazel.go",
"lifecycle.go",
"main.go",
"main_unix.go",
"main_windows.go",
"source_event_handler.go",
],
importpath = "github.com/bazelbuild/bazel-watcher/ibazel",
Expand Down
22 changes: 0 additions & 22 deletions ibazel/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (
"fmt"
"os"
"strings"
"syscall"
"time"
)

Expand Down Expand Up @@ -149,24 +148,3 @@ func handle(i *IBazel, command string, args []string) {
return
}
}

func setUlimit() error {
var lim syscall.Rlimit

err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &lim)
if err != nil {
return err
}

// set the "soft" file descriptor to the maximum
// allowed by a userspace program.
// http://man7.org/linux/man-pages/man2/getrlimit.2.html
lim.Cur = lim.Max

err = syscall.Setrlimit(syscall.RLIMIT_NOFILE, &lim)
if err != nil {
return err
}

return nil
}
40 changes: 40 additions & 0 deletions ibazel/main_unix.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// Copyright 2017 The Bazel Authors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// +build !windows

package main

import "syscall"

func setUlimit() error {
var lim syscall.Rlimit

err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &lim)
if err != nil {
return err
}

// set the "soft" file descriptor to the maximum
// allowed by a userspace program.
// http://man7.org/linux/man-pages/man2/getrlimit.2.html
lim.Cur = lim.Max

err = syscall.Setrlimit(syscall.RLIMIT_NOFILE, &lim)
if err != nil {
return err
}

return nil
}
19 changes: 19 additions & 0 deletions ibazel/main_windows.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Copyright 2017 The Bazel Authors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package main

func setUlimit() error {
return nil
}

0 comments on commit 31fffd0

Please sign in to comment.