This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { Worker, isMainThread, parentPort, workerData } = require('worker_threads'); | |
if (isMainThread) { | |
// This code runs in the main thread | |
const worker = new Worker(__filename, { | |
workerData: { number: 5 } // Send data to the worker thread | |
}); | |
worker.on('message', (result) => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { spawn } = require('child_process'); | |
// Function to calculate Fibonacci (same as before) | |
function fibonacci(n) { | |
if (n <= 1) { | |
return n; | |
} | |
return fibonacci(n - 1) + fibonacci(n - 2); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
gcc -o fork_execve_example fork_execve_example.c | |
chmod +x ./fork_execve_example | |
chmod +x ./test_script.sh |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <unistd.h> | |
#include <dirent.h> // For directory handling | |
#include <stdlib.h> // For exit() | |
void ls() { | |
// Open the directory | |
DIR *dir = opendir("."); | |
if (dir == NULL) { | |
perror("Unable to open directory"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. | |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
* | |
* This code is free software; you can redistribute it and/or modify it | |
* under the terms of the GNU General Public License version 2 only, as | |
* published by the Free Software Foundation. | |
* | |
* This code is distributed in the hope that it will be useful, but WITHOUT | |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async function callme(message, level) { | |
console.log(message, "entering", level) | |
level--; | |
// let req = new XMLHttpRequest(); | |
// req.open('GET', "https://thumbs.dreamstime.com/b/brown-dog-corso-corso-stands-field-green-grass-brown-dog-corso-cors-120197441.jpg"); | |
// req.onload = function () { | |
// if (req.status == 200) { | |
// console.log(req.status, "Download ok"); | |
// } else { |