---
name: "slurm_perror"
section: "3"
platform: "linux"
package: "libslurm-dev"
version: "20.11.7+really20.11.4-2+deb11u1"
release: "Debian 11 (Bullseye)"
platforms: ["linux"]
url: "https://new.carta.tech/slurm_get_errno"
---

# slurm\_perror(3)

Slurm error handling functions

Part of [slurm\_get\_errno(3)](/slurm_get_errno/3.md).

## NAME

slurm\_get\_errno, slurm\_perror, slurm\_strerror - Slurm error handling functions

## SYNTAX

\#include \<slurm/slurm\_errno.h\>

int **slurm\_get\_errno** ( );

void **slurm\_perror** (\
\
 	char \**header*\
 );

char \* **slurm\_strerror** (\
\
 	int *errnum*\
 );

## ARGUMENTS

- *errnum*

  A Slurm error code.

- *header*

  A pointer to a string used as a message header for printing along with an error description.

## DESCRIPTION

**slurm\_get\_errno** Return the error code as set by the Slurm API function executed.

**slurm\_perror** Print to standard error the supplied header followed by a colon followed by a text description of the last Slurm error code generated.

**slurm\_strerror** Given a Slurm error code, return a pointer to a text description of the error's meaning.

## RETURN VALUE

**slurm\_get\_errno** returns an error code or zero if no error was generated by the last Slurm function call executed. **slurm\_strerror** returns a pointer to a text string, which is empty if no error was generated by the last Slurm function call executed.

## EXAMPLE

\#include \<stdio.h\>\
 \#include \<slurm/slurm.h\>\
 \#include \<slurm/slurm\_errno.h\>

int main (int argc, char \*argv\[\])\
 {\
\
 	/\* assume Slurm API function failed here \*/\
\
 	fprintf (stderr, "Slurm function errno = %d\\n",\
\
 	         slurm\_get\_errno ());\
\
 	fprintf (stderr, "Slurm function errno = %d %s\\n",\
\
 	         slurm\_get\_errno (),\
\
 	         slurm\_strerror (slurm\_get\_errno ()));\
\
 	slurm\_perror ("Slurm function");\
\
 	exit (1);\
 }

## NOTE

These functions are included in the libslurm library, which must be linked to your process for use (e.g. "cc -lslurm myprog.c").

## COPYING

Copyright (C) 2002 The Regents of the University of California. Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). CODE-OCEC-09-009. All rights reserved.

This file is part of Slurm, a resource management program. For details, see \<https://slurm.schedmd.com/\>.

Slurm is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

Slurm is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details.

## SEE ALSO

[**slurm\_allocate\_resources**(3)](/slurm_allocate_resources/3.md), [**slurm\_complete\_job**(3)](/slurm_complete_job/3.md), [**slurm\_complete\_job\_step**(3)](/slurm_complete_job_step/3.md), [**slurm\_allocation\_lookup**(3)](/slurm_allocation_lookup/3.md), [**slurm\_free\_ctl\_conf**(3)](/slurm_free_ctl_conf/3.md), [**slurm\_free\_job\_info\_msg**(3)](/slurm_free_job_info_msg/3.md), [**slurm\_free\_job\_step\_create\_response\_msg**(3)](/slurm_free_job_step_create_response_msg/3.md), [**slurm\_free\_node\_info**(3)](/slurm_free_node_info/3.md), [**slurm\_free\_partition\_info**(3)](/slurm_free_partition_info/3.md), [**slurm\_free\_resource\_allocation\_response\_msg**(3)](/slurm_free_resource_allocation_response_msg/3.md), [**slurm\_free\_submit\_response\_response\_msg**(3)](/slurm_free_submit_response_response_msg/3.md), [**slurm\_get\_job\_steps**(3)](/slurm_get_job_steps/3.md), [**slurm\_init\_job\_desc\_msg**(3)](/slurm_init_job_desc_msg/3.md), [**slurm\_init\_part\_desc\_msg**(3)](/slurm_init_part_desc_msg/3.md), [**slurm\_job\_step\_create**(3)](/slurm_job_step_create/3.md), [**slurm\_job\_will\_run**(3)](/slurm_job_will_run/3.md), [**slurm\_kill\_job**(3)](/slurm_kill_job/3.md), [**slurm\_kill\_job\_step**(3)](/slurm_kill_job_step/3.md), [**slurm\_load\_ctl\_conf**(3)](/slurm_load_ctl_conf/3.md), [**slurm\_load\_jobs**(3)](/slurm_load_jobs/3.md), [**slurm\_load\_node**(3)](/slurm_load_node/3.md), [**slurm\_load\_partitions**(3)](/slurm_load_partitions/3.md), [**slurm\_pid2jobid**(3)](/slurm_pid2jobid/3.md), [**slurm\_reconfigure**(3)](/slurm_reconfigure/3.md), [**slurm\_shutdown**(3)](/slurm_shutdown/3.md), [**slurm\_submit\_batch\_job**(3)](/slurm_submit_batch_job/3.md), [**slurm\_update\_job**(3)](/slurm_update_job/3.md), [**slurm\_update\_node**(3)](/slurm_update_node/3.md), [**slurm\_update\_partition**(3)](/slurm_update_partition/3.md)
