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 occurs when you use I/O during camera recording operation.
I faced the same issue on using used I/O while recording.
So you can either add before recording or after not in between.