src/sample/nashorn/pgrep.js
author redestad
Wed, 10 Apr 2019 20:03:07 +0200
changeset 54492 9d0ae9508d53
parent 47261 ae970828ec0c
permissions -rw-r--r--
8222029: Optimize Math.floorMod Reviewed-by: aph, darcy
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
47261
ae970828ec0c 8187934: dropping a shebang script in src/sample/nashorn directory results in test failure
sundar
parents:
diff changeset
     1
#!/usr/bin/jjs --language=es6 
ae970828ec0c 8187934: dropping a shebang script in src/sample/nashorn directory results in test failure
sundar
parents:
diff changeset
     2
ae970828ec0c 8187934: dropping a shebang script in src/sample/nashorn directory results in test failure
sundar
parents:
diff changeset
     3
/*
ae970828ec0c 8187934: dropping a shebang script in src/sample/nashorn directory results in test failure
sundar
parents:
diff changeset
     4
 * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
ae970828ec0c 8187934: dropping a shebang script in src/sample/nashorn directory results in test failure
sundar
parents:
diff changeset
     5
 *
ae970828ec0c 8187934: dropping a shebang script in src/sample/nashorn directory results in test failure
sundar
parents:
diff changeset
     6
 * Redistribution and use in source and binary forms, with or without
ae970828ec0c 8187934: dropping a shebang script in src/sample/nashorn directory results in test failure
sundar
parents:
diff changeset
     7
 * modification, are permitted provided that the following conditions
ae970828ec0c 8187934: dropping a shebang script in src/sample/nashorn directory results in test failure
sundar
parents:
diff changeset
     8
 * are met:
ae970828ec0c 8187934: dropping a shebang script in src/sample/nashorn directory results in test failure
sundar
parents:
diff changeset
     9
 *
ae970828ec0c 8187934: dropping a shebang script in src/sample/nashorn directory results in test failure
sundar
parents:
diff changeset
    10
 *   - Redistributions of source code must retain the above copyright
ae970828ec0c 8187934: dropping a shebang script in src/sample/nashorn directory results in test failure
sundar
parents:
diff changeset
    11
 *     notice, this list of conditions and the following disclaimer.
ae970828ec0c 8187934: dropping a shebang script in src/sample/nashorn directory results in test failure
sundar
parents:
diff changeset
    12
 *
ae970828ec0c 8187934: dropping a shebang script in src/sample/nashorn directory results in test failure
sundar
parents:
diff changeset
    13
 *   - Redistributions in binary form must reproduce the above copyright
ae970828ec0c 8187934: dropping a shebang script in src/sample/nashorn directory results in test failure
sundar
parents:
diff changeset
    14
 *     notice, this list of conditions and the following disclaimer in the
ae970828ec0c 8187934: dropping a shebang script in src/sample/nashorn directory results in test failure
sundar
parents:
diff changeset
    15
 *     documentation and/or other materials provided with the distribution.
ae970828ec0c 8187934: dropping a shebang script in src/sample/nashorn directory results in test failure
sundar
parents:
diff changeset
    16
 *
ae970828ec0c 8187934: dropping a shebang script in src/sample/nashorn directory results in test failure
sundar
parents:
diff changeset
    17
 *   - Neither the name of Oracle nor the names of its
ae970828ec0c 8187934: dropping a shebang script in src/sample/nashorn directory results in test failure
sundar
parents:
diff changeset
    18
 *     contributors may be used to endorse or promote products derived
ae970828ec0c 8187934: dropping a shebang script in src/sample/nashorn directory results in test failure
sundar
parents:
diff changeset
    19
 *     from this software without specific prior written permission.
ae970828ec0c 8187934: dropping a shebang script in src/sample/nashorn directory results in test failure
sundar
parents:
diff changeset
    20
 *
ae970828ec0c 8187934: dropping a shebang script in src/sample/nashorn directory results in test failure
sundar
parents:
diff changeset
    21
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
ae970828ec0c 8187934: dropping a shebang script in src/sample/nashorn directory results in test failure
sundar
parents:
diff changeset
    22
 * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
ae970828ec0c 8187934: dropping a shebang script in src/sample/nashorn directory results in test failure
sundar
parents:
diff changeset
    23
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
ae970828ec0c 8187934: dropping a shebang script in src/sample/nashorn directory results in test failure
sundar
parents:
diff changeset
    24
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
ae970828ec0c 8187934: dropping a shebang script in src/sample/nashorn directory results in test failure
sundar
parents:
diff changeset
    25
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
ae970828ec0c 8187934: dropping a shebang script in src/sample/nashorn directory results in test failure
sundar
parents:
diff changeset
    26
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
ae970828ec0c 8187934: dropping a shebang script in src/sample/nashorn directory results in test failure
sundar
parents:
diff changeset
    27
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
ae970828ec0c 8187934: dropping a shebang script in src/sample/nashorn directory results in test failure
sundar
parents:
diff changeset
    28
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
ae970828ec0c 8187934: dropping a shebang script in src/sample/nashorn directory results in test failure
sundar
parents:
diff changeset
    29
 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
ae970828ec0c 8187934: dropping a shebang script in src/sample/nashorn directory results in test failure
sundar
parents:
diff changeset
    30
 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
ae970828ec0c 8187934: dropping a shebang script in src/sample/nashorn directory results in test failure
sundar
parents:
diff changeset
    31
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
ae970828ec0c 8187934: dropping a shebang script in src/sample/nashorn directory results in test failure
sundar
parents:
diff changeset
    32
 */
ae970828ec0c 8187934: dropping a shebang script in src/sample/nashorn directory results in test failure
sundar
parents:
diff changeset
    33
ae970828ec0c 8187934: dropping a shebang script in src/sample/nashorn directory results in test failure
sundar
parents:
diff changeset
    34
// simple process grep tool
ae970828ec0c 8187934: dropping a shebang script in src/sample/nashorn directory results in test failure
sundar
parents:
diff changeset
    35
ae970828ec0c 8187934: dropping a shebang script in src/sample/nashorn directory results in test failure
sundar
parents:
diff changeset
    36
java.lang.ProcessHandle.
ae970828ec0c 8187934: dropping a shebang script in src/sample/nashorn directory results in test failure
sundar
parents:
diff changeset
    37
    allProcesses().
ae970828ec0c 8187934: dropping a shebang script in src/sample/nashorn directory results in test failure
sundar
parents:
diff changeset
    38
    filter(ph => {
ae970828ec0c 8187934: dropping a shebang script in src/sample/nashorn directory results in test failure
sundar
parents:
diff changeset
    39
        var cmd = ph.info().commandLine();
ae970828ec0c 8187934: dropping a shebang script in src/sample/nashorn directory results in test failure
sundar
parents:
diff changeset
    40
        return cmd.isPresent() && cmd.get().search(arguments[0]) != -1;
ae970828ec0c 8187934: dropping a shebang script in src/sample/nashorn directory results in test failure
sundar
parents:
diff changeset
    41
    }).
ae970828ec0c 8187934: dropping a shebang script in src/sample/nashorn directory results in test failure
sundar
parents:
diff changeset
    42
    forEach(ph => print(ph.pid() + " " + ph.info().commandLine().get()));