Overhead cost of spawning child processes

I am curious as to the overhead cost of spawning child processes using fork in a Linux environment. Suppose I have a C program such as

void run_computation(int x);  int main() {     for (int k=0; k<10; k++) {         if ( fork() == 0 ) {             run_computation(k);             break;         }     }      return 0; } 

Assuming that no global state is modified by run_computation, how efficient in terms of overhead is the setting up of the child processes?

To help understand where I’m coming from, I’d like to write my own regex engine (for self-learning) and am imagining using fork to implement the NFA. So, am I incurring an unreasonable cost in such an implementation compared to other methods?

Unity 3D platform spawning problems

I’m making an infinite runner game in Unity 3D. I have it so that platforms spawn and move backwards toward the player and they are destroyed once past the player. Over time when the platforms are spawned, the position they’re spawned at gets more and more inaccurate. Sometimes they over lap slightly and sometimes there are small gaps in between them. And as the game is continuously played, it gets worse and worse. You can watch the video below to see what I mean. This is the script I use to spawn the object

 public GameObject[] objectSpawned;   public PlatformKiller myPlatformKiller;   void Start()  {      myPlatformKiller = GameObject.Find("PlatformKiller").GetComponent<PlatformKiller>();  }   private void Update()  {      if (myPlatformKiller.readyForSpawn)      {          int rand = Random.Range(0, objectSpawned.Length);          Instantiate(objectSpawned[rand], transform.position, transform.rotation * Quaternion.Euler (-90f, 0f, 0f));      }  } 

Here is a video so you can see what I’m talking about: https://youtu.be/eASouQlTsqs

Also, I know the exact unit size for each platform is 11.92. I know this because I added a c# script to each one that shows me the vector3 values. There are originally 20 platforms. And to know exactly where to spawn the object I did 11.92*20 = 238.4. And the first platform is at -4.78. So I subtracted that from 238.4 and got 233.62. So a z position of 233.62 is the correct place to spawn the object. I just wanted to include that in there so you know that the spawner gameobject is in the right place. Please let me know if there is any additional information about this that I can give you. Everything should theoretically work I think, so I seriously have no idea what to do. Thanks for your help!

readyForSpawn is set in my PlatformKiller script shown below:

public bool readyForSpawn;  void Update() {     readyForSpawn = false; }  void OnTriggerEnter(Collider target) {     if (target.tag == "Floor")     {         readyForSpawn = true;         Destroy(target.gameObject);     } } 

And that script is attached to PlatformKiller Game Object: PlatformKiller Picture

UNITY – Instantiate is spawning too many clones

just at a bit of an impasse with this one if anyone can help.

I am developing an endless runner, and I am trying to instantiate my obstacle prefabs by having my player go through a trigger which activates an instantiation. The problem I’m having is that when the player goes through the trigger, my code seems to instantiate multiple prefabs at a time. I’ll post screenshots and my codes to illustrate this better. Player hits the first trigger, instantiating 3 clones

Player hits the next trigger which instantiating even more clones

using System.Collections; using System.Collections.Generic; using UnityEngine;  public class ObsGenerator : MonoBehaviour {      public GameObject spawnTrigger;     public GameObject Player;     [SerializeField] private List<Transform> obstacleList;      public Transform spawnLocation;      public void OnTriggerEnter2D(Collider2D Player)     {         if (Player.CompareTag("Respawn"))         {            // for (int i = 0; i < obstacleList.Count; i++)             {                 spawnObstacle();                              }         }     }      public void spawnObstacle()     {         for (int i = 0; i < obstacleList.Count; i++)              if (obstacleList.Count > 0)             {                 Transform chosenLevelPart = obstacleList[Random.Range(0, obstacleList.Count)];                 Instantiate(chosenLevelPart);             }         }     }

Really appreciate anybody’s help!

How to implement arcade-style spawning?

In many arcade-style games with a horizontally scrolling camera, enemies spawn offscreen, either left or right, and traverse the screen in the opposite direction.

Spawning enemies is easy enough, but my question concerns the logic of getting them to spawn in an arcade-type way, just offscreen and according to the predefined patterns of the designer.

One idea I thought of was designating trigger areas in my level. When the player enters a trigger, enemy spawn points associated with that trigger then spawn enemies. But with a scrolling camera, sometimes as the camera scrolls, those spawn points enter the viewport and enemies spawn on screen out of nowhere.

What is a good technique to achieve arcade-style enemy spawns?

Here are two examples of the types of spawns I am thinking about:

https://youtu.be/Z7lAZExM21k?t=310 (Blazing Chrome by Joymasher) https://youtu.be/UAOFcpOfOVs?t=362 (Nightmare Busters by Arcade Zone)

Failed at step EXEC spawning… Permission denied

I have read alot about this but still not sure why this is not working. as far as I know all dirs have the right permission and even with everything being 777 I still get permission denied when trying to run this program as a service. the program I am trying to run as a servoce is called xTeVe. I have tried runing it under all differient dirs, users, and nothing seems to work.

Heres the Unit file:

[Unit] Description=XTeVe For Plex After=network.target network-online.target  [Service] ExecStart=/root/IPTV/xteve user=root Restart=on-failure RestartSec=5 StartLimitInterval=60s StartLimitBurst=3  [Install] WantedBy=multi-user.target 

I do know that this shouldnt be run as root but that was just the last user I tried

And when i try to start the service i get this:

14:20 xteve.service: Failed with result 'exit-code'. 14:02 xteve.service: Main process exited, code=exited, status=203/EXEC 14:02 xteve.service: Failed at step EXEC spawning /root/IPTV/xteve: Permission denied 14:02 xteve.service: Failed to execute command: Permission denied 14:02 Started XTeVe For Plex. 

And this is the file permissions:

[root@skynet IPTV]# ls -la total 12084 drwxr-xr-x. 2 root root       19 Mar  6 13:58 . dr-xr-x---. 5 root root      175 Mar  6 13:58 .. -rwxr-xr-x. 1 root root 12370316 Mar  6 13:58 xteve 

Things I have tried but didnt work:

systemd Failed at step EXEC spawning script: Permission denied

systemd custom service: Failed at step EXEC spawning … Permission denied

“Failed at step EXEC spawning” even with proper group permissions

How can I update the contents of the tkinter listbox without it spawning a new listbox?

Can anyone help me with my problem please? How can I update the contents of the tkinter listbox without it creating a new listbox with the updated information? The below code snippet will create to text field boxes as well as some buttons. The insert button will take what is typed in the textboxes and saves it in a sqlite database. The Clear button will clear the text fields.

The area I’m having the most problem is with the read button, because when the button is pressed the do_read method will generate a new listbox every time information is updated in the listbox. How can I get it to only have one listbox that is updated with the new information from the sqlite database. Thank you

import tkinter as tk from tkinter import * import sqlite3 as lite  currentpage = 0 previous = 1 global house global window  class MyApp: def __init__(self): global house global window window = Tk() window.title('My application')  frame = Frame(window) frame.pack()  self.fields = {}  l = Label(frame, text="Name:") l.grid(row=0, column=0) self.fields['name'] = Entry(frame) self.fields['name'].grid(row=0, column=1) self.fields['people'] = Entry(frame) d = Label(frame, text="People:") d.grid(row=0, column=2) self.fields['people'].grid(row=0, column=3)  submitbtn = Button(frame, text="Insert", command=self.do_insert) submitbtn.grid(row=11, column=0)  clearbtn = Button(frame, text="Clear", command=self.do_clear) clearbtn.grid(row=11, column=1)  readbtn = Button(frame, text="Read", command=self.do_read) readbtn.grid(row=11, column=2) action = readbtn  house = tk.StringVar()  CLOSEbtn = Button(frame, text="CLOSE APPLICATION", command=window.destroy).grid(row=11, column=3) #house = tk.StringVar() #Label(frame, textvariable=house).grid(column=4, row=4)    window.mainloop()  def do_clear(self): self.fields['name'].delete(0,END) self.fields['people'].delete(0,END)  def do_insert(self): global currentpage, previous con = lite.connect('RandomThings.db') cur = con.cursor() cur.execute("CREATE TABLE IF NOT EXISTS Magazines(name TEXT, people TEXT)") cur.execute("INSERT INTO Magazines(name, people) VALUES (?, ?)", (self.fields['name'].get(), self.fields['people'].get())) rows = cur.execute("SELECT * FROM Magazines")   con.commit()  def do_read(self):   con = lite.connect('RandomThings.db')   cur = con.cursor()   cur.execute('SELECT * FROM Magazines')   data = cur.fetchall()   print(data)    house.set(data)   frame = Scrollbar(window)   frame.pack( side = RIGHT, fill = Y )   mylist = Listbox(window, yscrollcommand = frame.set )   for line in data:       mylist.insert(END, " " + str(line))       print(line)    mylist.pack( side = RIGHT, fill = BOTH )   frame.config( command = mylist.yview )   if __name__=="__main__": MyApp()