How to make a simple bitcoin hard fork

I am exploring bitcoin source code for some time and have successfully created a local bitcoin network with new genesis block.
Now i am trying to understand the process of hard forks (if i am using wrong terms here, i am referring to the one where the blockchain is split instead of mining a new genesis).
I am trying find this approach in BitcoinCash source code, but haven’t got anywhere so far except the checkpoints.

//UAHF fork block.   {478558, uint256S("0000000000000000011865af4122fe3b144e2cbeea86"           "142e8ff2fb4107352d43") } 

So for i understand that the above checkpoint is responsible for the chain split. But i am unable to find the location in source code where this rule is enforced, i.e. the code where it is specified to have a different block than bitcoin after block number 478558.
Can anyone set me into the right direction here?

Reward in case of fork

Hi I would like to ask you guys for some details about getting reward from minning block when there is a fork – two miners get different blocks at the same time. Both of these block will have the coinbase transaction. Does it means that both of users wallets will have information about this transaction? If yes what will happen when both users will quickly go to bitcoin’s ATM and take fiat currency from this reward?

Bitcoin fork resolution – Fork losers download previous blocks ’til common block?

When resolving a naturally occurring fork in Bitcoin, do the miners who were working on the orphaned fork download previous blocks from the miner who won the block reward that resolved the fork until they find a common block?

My understanding is that miners accept a new block as long as it is valid. As long as it’s one block, they can just add it to their local version and start on the next block. However, if they receive a new block that is the head of a different fork that split off from their fork 10 blocks previously, how do the miners of the orphaned fork get the blocks from the other fork? How do they know to?

Bitcoin fork resolution – Fork losers download previous blocks ’til common block?

When resolving a naturally occurring fork in Bitcoin, do the miners who were working on the orphaned fork download previous blocks from the miner who won the block reward that resolved the fork until they find a common block?

My understanding is that miners accept a new block as long as it is valid. As long as it’s one block, they can just add it to their local version and start on the next block. However, if they receive a new block that is the head of a different fork that split off from their fork 10 blocks previously, how do the miners of the orphaned fork get the blocks from the other fork? How do they know to?

Using fork() for monitoring files and making backups

I wrote program which can monitor files every second (or rare). It stores in its memory content of file and if it notices that file was modified it will write last version into some txt file and remember new version. Every file has its own process made by fork(). I am wondering why after writing backup to file and reading new version process stops. I solved it by making another process in currently working, but it gives me sleepless nights. Is there any explanation for that?

I used fork to create a child process but I can’t achieve communication between parent and child with signals [on hold]

I have an assignment for my OS class where we have to create a child process using fork(). Once that is done, the child has to be in pause() state, waiting for a signal from the parent process. The parent process needs to “activate” the child and once that happens the commands within the child’s body should be executed. We are required to use the kill() and signal() function. We write in C. Excuse me if I’m not explaining the assignment well but I have been trying to establish communication between the parent and child using signals and I simply can’t.The lecturer specifies that he wants us to add delays with sleep(). I know that there are other commands such as raise() but we are specifically required to use kill(), wait() and signal(). Here’s what I did:

void handler(int sig) {   if (sig==SIGCONT)   {     printf("I received SIGCONT\n");     sleep(1);     exit(0);   } } int main(void) {   pid_t c1=fork();   if (c1<0)   {       printf("error\n");      exit(-1);   }   else if (c1==0)   {     c1=getpid();     pause();     signal(SIGCONT,handler);     sleep(1);   }   else  {     kill(c1,SIGCONT);     sleep(1);     int status;     wait(&status);     exit(0);  } return 0; } 

Node.js child process fork return response — Cannot set headers after they are sent to the client

copied from stack overflow since no one could answer.

situation: have an function that does an expensive operation such as fetching a large query from mongodb, then performing a lot of parsing and analysis on the response. I have offloaded this expensive operation to a child process fork, and waiting for the worker to be done before sending response in order to not block the main event loop.

current implentation: I have an API endpoint GET {{backend}}/api/missionHistory/flightSummary?days=90&token={{token}}

api entry point code:

missionReports.js

const cp = require('child_process'); //if reportChild is initailzed here, "Cant send headers after they were sent" const reportChild = cp.fork('workers/reportWorker.js');   exports.flightSummary = function (req, res) {     let request = req.query;      // if initialized here, there is no error.      const reportChild = cp.fork('workers/reportWorker.js');      logger.debug(search_query);      let payload = {'task':'flight_summary', 'search_params': search_query};     reportChild.send(payload);      reportChild.on('message', function (msg) {        logger.info(msg);         if (msg.worker_status === 'completed')        {            return res.json(msg.data);        }       }); }; 

worker code: reportWorker.js

process.on('message', function (msg) {     process.send({'worker_status': 'started'});     console.log(msg);     switch(msg.task)     {         case 'flight_summary':             findFlightHours(msg.search_params,function (response) {                 logger.info('completed')                 process.send({'worker_status': 'completed', 'data':response});             })         break;     }   }); 

scenario 1: reportChild (fork) is initialized at beginning of module definitions. api call works once, and returns correct data. on second call, it crashes with cannot send headers after theyve been sent. I stepped through the code, and it definitely only sends it once per api call.

scenario 2: if i initalize the reportChild inside of the api definition, it works perfectly every time. Why is that? Is the child forked process not killed unless its redefined? Is this standard implementation of child proceses?

This is my first attempt at threading in node.js, I am trying to move expensive operations off of the main event loop into different workers. Let me know what is best practice for this situation. Thanks.