I want to use Raspberry PI's system command `raspistill`to take images in a c program, the program line is: `system("raspistill -q 5 -vf -hf -o pic1.jpg -t 1 -th 0:0:0");`

However, when I run the program sometimes error occurs, 
it shows that:

> 
> mmal\_vc\_component\_enable- failed to enable component- ENOSPC
>  mmal- camera component couldn't be enabled
>  mmal- main- Failed to create camera component
>  mmal- Failed to run camera app. Please check for firmware updatesckquote
> 
> 
> 

And I have tried to add some parameters into /boot/config.txt:

> 
> gpu\_mem=128 start\_file=start\_x.elf fixup\_file=fixup\_x.dat  
> 
>  disable\_camera\_led=1 cam\_lwm=16 cam\_hwm=32 cam\_offline\_start=16
> 
> 
> 

However the error still always occurs sometimes (sometimes ok). I really want to solve this problem in order to continue my project. What should I do?
['https://Stackoverflow.com/questions/29314841', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/4407689/']
Stop any other processes using the camera (e.g.raspimjpeg)

```
$ ps -aux

```

// locate the process pid and kill it using the pid number (e.g. 764)

```
$ sudo kill 764

```

Note: You might have more than one process running so be sure to kill them all before trying again.
This error will appear when the RPi Camera is "On" and is streaming. The component: ENOSPC cannot start unless the RPi Camera is not streaming or being used by another process.
One solution is to try to stop the Camera stream before the Snapshot and then restart it after.