---
name: "kthread_create"
section: "9"
platform: "linux"
package: "linux-manual-2.6.32"
version: "2.6.32-48squeeze6"
release: "Debian 6.0 (Squeeze)"
platforms: ["linux", "freebsd"]
url: "https://new.carta.tech/kthread_create"
---

# kthread\_create(9)

create a kthread.

## NAME

kthread\_create - create a kthread.

## SYNOPSIS

**struct task\_struct \* kthread\_create(int (\****threadfn***) (void \*data), void \*** *data***, const char** *namefmt\[\]***,** *...***);**

## ARGUMENTS

*threadfn*

the function to run until signal\_pending(current).

*data*

data ptr for *threadfn*.

*namefmt\[\]*

printf-style name for the thread.

*...*

variable arguments

## DESCRIPTION

This helper function creates and names a kernel thread. The thread will be stopped: use **wake\_up\_process** to start it. See also **kthread\_run**, **kthread\_create\_on\_cpu**.

When woken, the thread will run *threadfn*() with *data* as its argument. *threadfn*() can either call **do\_exit** directly if it is a standalone thread for which noone will call **kthread\_stop**, or return when '**kthread\_should\_stop**' is true (which means **kthread\_stop** has been called). The return value should be zero or a negative error number; it will be passed to **kthread\_stop**.

Returns a task\_struct or ERR\_PTR(-ENOMEM).

## COPYRIGHT
