what are the ways that a process can be created in UNIX apart from fork/vfork?

Dani AI

Generated

To : a few clarifications and practical alternatives to calling fork/vfork directly.

As and noted, people often mention exec and system. Important correction: an exec-family call does not create a new process — it replaces the current process image (execve(2)). system() is a libc wrapper that usually does a fork+exec and invokes a shell (system(3)). If the goal is "spawn a new process" without manually doing fork+exec, look at these real alternatives.

Portable, higher-level spawn: POSIX provides posix_spawn/posix_spawnp. It combines creation+exec semantics in one API, supports fd/file-action and attr structures, and is safer in multithreaded programs because it avoids the risky fork-before-exec window (posix_spawn(3)). Use this when you only need to set up standard fds, signal masks, or attributes before exec.

Linux-specific low-level control: clone/clone3 lets you create a new task with fine-grained sharing flags (the basis of threads, containers, and low-level process managers). It is powerful but complex and nonportable (clone(2)). In practice, service managers and schedulers (systemd, cron, inetd, shells) start processes for you, but they ultimately call kernel primitives. Recommendation: prefer posix_spawn for portable, thread-safe spawning; use clone only when you need its special semantics or are writing low-level system code.

Recommended Answers

All 2 Replies

exec

i think that create a process in unix is like nearly with create process in linux .
you can use system called that is fork(),exec(), or system();

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.